I need help please with IE 11 and jQuery in getting the selected options. (It works fine in Edge.) I've tried many links here and elsewhere but without success.
UPDATE If I remove the function .mousedown, then the onchange function works as expected. so the question then is how to accumulate all the selections (without using the Ctrl Key) before posting those back via ajax.
It also does not display the checkboxes in IE11, but that's a different question. Thanks in Advance.
Markup:
<style>
option:before {
content: "☐ "
}
option:checked:before {
content: "☑ "
}
<select class="ddlRole" id="ddlRole" style="width:810px" size="6" multiple="">
<option value="1">Administrator</option>
<option value="2">Manager</option>
<option value="3">User</option>
<option value="8">new role test 5</option>
</select>
The jQuery: This mousedown function allows the user to select multiple options from the list
$("#ddlRole").mousedown(function (e)
{
e.preventDefault();
var select = this;
var scroll = select.scrollTop;
e.target.selected = !e.target.selected;
setTimeout(function () { select.scrollTop = scroll; }, 0);
$(select).focus();
$("#ddlRole").trigger("change");
}).mousemove(function (e) { e.preventDefault() });
$('#ddlRole').on('change', function ()
{
// Works in Edge but not IE11
var selectedValue = $("#ddlRole").find('option:selected').val();
alert("try .." + selectedValue);
});