0
結尾
我在所有行中都有一個輸入表,我需要檢查是否所有輸入都填充了值 我試圖使用選擇器$(「[id $ ='txtBarcode' ]「)選擇以txtBarcode結尾的所有輸入,但似乎不起作用。 有什麼問題?所有文本的jquery選擇符以
$(document).ready(function() {
$("#cmdConferma").click(function() {
AllFilled();
});
});
function AllFilled() {
$("[id$='txtBarcode']").each(function() {
$this = $(this);
// var value = $("[id$='txtBarcode']").value();
if ($this.value() == '') {
return confirm('are you sure to exit without fill?');
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="table_style" cellspacing="0" rules="all" border="1" id="dgrRighe" style="width:100%;border-collapse:collapse;">
<tr>
<td>
<input name="dgrRighe$ctl02$txtBarcode" type="text" value="1" id="dgrRighe_ctl02_txtBarcode" />
</td>
<td>
<input name="dgrRighe$ctl03$txtBarcode" type="text" id="dgrRighe_ctl03_txtBarcode" />
</td>
<td>
<input name="dgrRighe$ctl04$txtBarcode" type="text" id="dgrRighe_ctl04_txtBarcode" />
</td>
</tr>
</table>
<input type="submit" name="cmdConferma" value="exit" id="cmdConferma" class="button" />
'.value()'在javascript中也不是方法。它的一個屬性。爲了使用'.value',不需要將dom對象轉換成jquery對象。使用'this.value'將返回值 –