I started from @vitfo answer but I want to have <option>
inside <select>
instead of checkbox inputs so i put together all the answers to make this, there is my code, I hope it will help someone.
$(".multiple_select").mousedown(function(e) {_x000D_
if (e.target.tagName == "OPTION") _x000D_
{_x000D_
return; //don't close dropdown if i select option_x000D_
}_x000D_
$(this).toggleClass('multiple_select_active'); //close dropdown if click inside <select> box_x000D_
});_x000D_
$(".multiple_select").on('blur', function(e) {_x000D_
$(this).removeClass('multiple_select_active'); //close dropdown if click outside <select>_x000D_
});_x000D_
_x000D_
$('.multiple_select option').mousedown(function(e) { //no ctrl to select multiple_x000D_
e.preventDefault(); _x000D_
$(this).prop('selected', $(this).prop('selected') ? false : true); //set selected options on click_x000D_
$(this).parent().change(); //trigger change event_x000D_
});_x000D_
_x000D_
_x000D_
$("#myFilter").on('change', function() {_x000D_
var selected = $("#myFilter").val().toString(); //here I get all options and convert to string_x000D_
var document_style = document.documentElement.style;_x000D_
if(selected !== "")_x000D_
document_style.setProperty('--text', "'Selected: "+selected+"'");_x000D_
else_x000D_
document_style.setProperty('--text', "'Select values'");_x000D_
});
_x000D_
:root_x000D_
{_x000D_
--text: "Select values";_x000D_
}_x000D_
.multiple_select_x000D_
{_x000D_
height: 18px;_x000D_
width: 90%;_x000D_
overflow: hidden;_x000D_
-webkit-appearance: menulist;_x000D_
position: relative;_x000D_
}_x000D_
.multiple_select::before_x000D_
{_x000D_
content: var(--text);_x000D_
display: block;_x000D_
margin-left: 5px;_x000D_
margin-bottom: 2px;_x000D_
}_x000D_
.multiple_select_active_x000D_
{_x000D_
overflow: visible !important;_x000D_
}_x000D_
.multiple_select option_x000D_
{_x000D_
display: none;_x000D_
height: 18px;_x000D_
background-color: white;_x000D_
}_x000D_
.multiple_select_active option_x000D_
{_x000D_
display: block;_x000D_
}_x000D_
_x000D_
.multiple_select option::before {_x000D_
content: "\2610";_x000D_
}_x000D_
.multiple_select option:checked::before {_x000D_
content: "\2611";_x000D_
}
_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>_x000D_
<select id="myFilter" class="multiple_select" multiple>_x000D_
<option>A</option>_x000D_
<option>B</option>_x000D_
<option>C</option>_x000D_
<option>D</option>_x000D_
<option>E</option>_x000D_
</select>
_x000D_