Dictionaries (Merriam-Webster and New Oxford American Dictionary) have deselect but not unselect. The NOAD defines deselect as “turn off (a selected feature) on a list of options on a computer menu”, which is what you want.
Pressing the Ctrl key, you can click, or click-and-drag to deselect any cells or ranges within a selection.
Syntax of jQuery Select Option$(“selector option: selected”); The jQuery select option is used to display selected content in the option tag. text syntax is below: var variableValue = $(“selector option: selected”).
Use removeAttr...
$("option:selected").removeAttr("selected");
Or Prop
$("option:selected").prop("selected", false)
There are lots of answers here but unfortunately all of them are quite old and therefore rely on attr
/removeAttr
which is really not the way to go.
@coffeeyesplease correctly mentions that a good, cross-browser solution is to use
$("select").val([]);
Another good cross-browser solution is
// Note the use of .prop instead of .attr
$("select option").prop("selected", false);
You can see it run a self-test here. Tested on IE 7/8/9, FF 11, Chrome 19.
$('select').val('')
I simply used this on the select itself and it did the trick.
I'm on jQuery 1.7.1.
It's a been a while since asked, and I haven't tested this on older browsers but it seems to me a much simpler answer is
$("#selectID").val([]);
.val() works for select as well http://api.jquery.com/val/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With