我有幾個選擇框和文本框與相同的類,我有以下聲明。 修訂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