[英]Get Value of each Element of all Row and Column of a Table
好吧,我有一張桌子,桌子上有不同的元素,例如文本框,文本區域和復選框。
我正在使用此代碼:
$('#tablaCorrectiva tr').not(':first').each(function() {
alert($(this).children("td:nth-child(1)").val()); //Get BLANK
alert($(this).children("td:nth-child(1)")); // GET "[object Object]"
}
但是我沒有得到元素的價值。
我嘗試過:
$(this).children("td:nth-child(3)").find('.acc_correc').val()
但是我不確定。
請幫忙
采用
alert($(this).children("td:nth-child(1)").html());
代替
alert($(this).children("td:nth-child(1)").val());
檢查小提琴
試試這個鱈魚
<table id=tablaCorrectiva >
<thead>
<tr><th>code</th></tr>
</thead>
<tbody>
<tr><td><input value="pippo"></td></tr>
<tr><td><input value="pluto"></td></tr>
<tr><td><input value="paperino"></td></tr>
</tbody>
<table>
/*Suppose the first TR is head and it is under <thead></thead>*/
$('#tablaCorrectiva > tbody > tr > td').each(function(index,value) {
alert($(value).find("textarea,input").val());
});
試試這個
alert($(this).children("td:nth-child(3)").find(':input').val());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.