how do you unselect all items from a listbox using jquery
jQuery is designed to work with multiple elements at the same time:
$(listboxSelector).find("option").attr("selected", false);
$('#myListbox option').attr('selected',false);
The shortest way is this method:
$("#myListBox").val([]);
This sets the value to an empty array, meaning select no values. .val()
takes an array in the case of a <select multiple>
element. Note that $("select").val('');
also works here :)