I have a list in a select. After selecting an option i do a check and occasionally i want to change the selected to index 0 (first option, value=""). How do i set the select to that option with jquery?
Here's an extension method that will do this so you can simplify your inline syntax
<!-- language-all: lang-js -->$.fn.extend({
deselect: function() {
this.filter("select").each(function() {
$("option", this)[0].selected = true;
});
}
});
Then, you can call it like this:
$("#selector").deselect();
Here's a demo: