<select size="2">
<option selected="selected">Input your option</option>
<option>Input your option</option>
</select>

使用jQuery优雅地取消选项的最佳方法是什么?


当前回答

另一种简单的方法:

$ (" # selectedID”)[0 - 9]。选择= -1

其他回答

$("option:selected").attr("selected", false);
$("#selectID option:selected").each(function(){
  $(this).removeAttr("selected");
});

这将遍历每个项目,只取消选中的项目

简单的方法

(“select”美元)。瓦尔(”)

我只是在select本身上使用了这个,它做到了。

我使用的是jQuery 1.7.1。

使用removeAttr……

$("option:selected").removeAttr("selected");

或道具

$("option:selected").prop("selected", false)

另一种简单的方法:

$ (" # selectedID”)[0 - 9]。选择= -1