我想要像這樣使用jquery來獲取td的值。如何使用jQuery獲取TD值?
$("#id").find(".class").attr('value');
//or
$("#id").find(".class").val();
兩者都返回空字符串,雖然它有一個值。 請注意*我正在嘗試獲取動態創建的元素的值。 在此先感謝。
我想要像這樣使用jquery來獲取td的值。如何使用jQuery獲取TD值?
$("#id").find(".class").attr('value');
//or
$("#id").find(".class").val();
兩者都返回空字符串,雖然它有一個值。 請注意*我正在嘗試獲取動態創建的元素的值。 在此先感謝。
只要寫
$("#id .class").text();
或獲得的HTML使用,
$("#id .class").html();
HTML:
<table>
<tr>
<td class="tdcls">1</td>
<td class="tdcls">2</td>
<td class="tdcls">3</td>
</tr>
<tr>
<td class="tdcls">4</td>
<td class="tdcls">5</td>
<td class="tdcls">6</td>
</tr>
</table>
jQuery代碼來選擇特定的td
值:
$(".tdcls").mouseenter(function(){
var a = $(this).text();
});
分享您的HTML結構 –
檢查這篇文章如何讓表格單元格TD值的http:// codepedia。 info/jquery-get-table-cell-td-value-div/ –