开发者

Remove selection of particular value in multiple select box

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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜