设置.selectedIndex我有一些HTML选择:如何用jQuery
<select class="form-control, dropdown" id="delperffrom" name="delperffrom">
. . .
<select class="form-control, dropdown" id="delperfto" name="delperfto">
. . .
我要初始化他们 “没有价值”,因此有这个JavaScript的,其工作方式:
document.getElementById("delperffrom").selectedIndex = -1;
。 。这个jQuery并没有:
$("#delperfto").selectedIndex = -1;
为什么jQuery不起作用?
因为...'$()'不返回一个DOM节点?阅读文档。 http://api.jquery.com/jQuery - > http://api.jquery.com/Types/#jQuery –
不相关但css类仅由空格分隔。 –
https://api.jquery.com/?s=selectedIndex显示此属性不存在,但显示可用于更改'selectedIndex'的方法。 –