使用jquery获取表的值

时间:2017-04-21 11:15:21

标签: javascript jquery json

我有一张桌子,我需要获得该桌子的一些价值。我试过但不能

在这里,我想获得7700-5-3300-4455价值。(在第一个输入栏中)

我的表格HTML

 <table id="inUti">
 <tbody><tr></tr><tr class="x1">
 <td><input id="nid45global" disabled="" class="form-control" value="7700-5-3300-4455" type="text"></td>
 <td><input id="nid55local" class="form-control" value="1/2" type="text"></td>
 </tr>
 </tbody></table>

我试过这样。

   var newsLocator = $("#inUti").closest('tr').children('tr').children('td:first').text(); // Thisone returns Empty 

3 个答案:

答案 0 :(得分:0)

最简单的选择是使用therir ID

选择它们
$("#nid45global").val();

如果您想特定于该表,

$("#inUti").find('.x1 td input#nid45global').val();

或者

$("#inUti .x1").find("td:first-child input").val();

答案 1 :(得分:0)

只需说$(“#inUti input”)。val(); 另一种方式!

答案 2 :(得分:-1)

尝试这个动态获取价值

$(#inUti").find(".x > td:nth-child(1) > input").val();

这将根据您的要求提供实际结果