我有一个带有许多选择标签的 from,当用户提交表单时,我想检查用户是否为所有选择标签选择一个选项,这是我的 jquery 代码
$('#apForm select').each(function(){
var $this = $(this);
if ($this.selectedIndex == 0){
var error = 'fill this please' ;
$this.next('span').text(error);
errorCount = errorCount + 1;
}
});
我尝试这样
$this.attr("selectedIndex")
我只是给你我的问题所在的代码片段
如果我应该提供更多代码告诉我
谢谢你的帮助
var $this = $(this);
if($this.get(0).selectedIndex == 0) {
}
或者只是简单的
this.selectedIndex; // not $this / $(this)
If no option
它会返回-1
在这里我展示了以上所有案例 http://jsfiddle.net/thecodeparadox/HvG99/5/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)