I am think this should be fairly easy, but struggling a bit … I have a SELECT input element that allows the user to select multiple items. I would like to provide a mechanism for them to clear all selected items, probably will just be a SPAN tag or something similar.
Anyway … using jQuery, how I would I clear the selection on the SELECT input element so no items are selected.
In the case of a
<select multiple>the.val()function takes/returns an array, so you can simply pass in an empty array to clear the selection, like this:You can test it out here.