我有几个选择框和文本框与相同的类,我有以下声明。 修订JQuery。检查相同类的选择框和文本框的值,有可能吗?
//This goes through each visible tr of the table with class notEmptyTable
$('.notEmptyTable tr:visible').each(function(index) {
//This checks that the elements with class checkTextBox1IsNotEmpty its not Empty.
if ($('.checkTextBox1IsNotEmpty ').val() != "") {
if ($('.selTxtClass:visible').val() == "") {
$('.selTxtClass:visible').focus();
}
}
});
更新HTML
<table>
<tr>
<td><input type="text" id="txtBoxa1" class="checkTextBox1IsNotEmpty"/></td>
<td><input type="text" id="txtBoxb1" /></td>
<td><select id="selc1" class="selTxtClass" onchange="javascript:if (this.value = "other")txtBoxd1.style.display = 'block'"/>
<input id="txtBoxd1" style="display:none;" class="selTxtClass"/>
</td>
</tr>
<tr>
<td><input type="text" id="txtBoxa1" class="checkTextBox1IsNotEmpty"/></td>
<td><input type="text" id="txtBoxb1" /></td>
<td><select id="selc1" class="selTxtClass" onchange="javascript:if (this.value = "other")txtBoxd1.style.display = 'block'"/>
<input id="txtBoxd1" style="display:none;" class="selTxtClass"/>
</td>
</tr>
<tr>
<td><input type="text" id="txtBoxa1" class="checkTextBox1IsNotEmpty"/></td>
<td><input type="text" id="txtBoxb1" /></td>
<td><select id="selc1" class="selTxtClass" onchange="javascript:if (this.value = "other")txtBoxd1.style.display = 'block'"/>
<input id="txtBoxd1" style="display:none;" class="selTxtClass"/>
</td>
</tr>
</table>
如果我做一个警报($( 'selTxtClass:可见')VAL()),它作为不确定的。
我想检查这些元素的值是否为空,但是我不能看到这个if语句有什么问题,请问您能帮我一下吗?
非常感谢。
您还需要发布标记:) – 2010-05-07 11:48:39
@ Nick Craver:给我一秒钟。 – Amra 2010-05-07 11:55:09