Best way to unselect a <select> in jQuery?
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.
Simplest Method
$('select').val('')
I simply used this on the select itself and it did the trick.
I'm on jQuery 1.7.1.