I have a multi-select box that has multiple items:
<select id="foo">
<option value="bar1">bar1</option>
<option value="bar2">bar2</option>
<option value="bar3">bar3</option>
<option value="bar4">bar4</option>
开发者_运维技巧 <option value="bar5">bar5</option>
</select>
Let's assume bar2, bar3 and bar5 are selected. I want to 'unselect' bar3.
How do I use jQuery to 'unselect' just bar3, leaving bar2 and bar5 selected?
$('#foo option[value=bar3]').attr('selected', false);
$("#foo>option[value=bar3]").removeAttr("selected");
精彩评论