Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery如何在动态表中选择当前TD的第n个子项_Jquery - Fatal编程技术网

jquery如何在动态表中选择当前TD的第n个子项

jquery如何在动态表中选择当前TD的第n个子项,jquery,Jquery,这对你们中的一些人来说可能很简单,但我有点麻烦。我想得到TD的TR中第一个TD的值,该TD有一个已选中的复选框。 警告第n个孩子的CSS的代码行只是我选择TD的最后一次尝试 $('.notdupe').live('click', function (e) { //alert("indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked")); $.ajax({

这对你们中的一些人来说可能很简单,但我有点麻烦。我想得到TD的TR中第一个TD的值,该TD有一个已选中的复选框。 警告第n个孩子的CSS的代码行只是我选择TD的最后一次尝试

$('.notdupe').live('click', function (e) {
        //alert("indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked"));
        $.ajax({
          type: "POST",
          url: "cfc/basic.cfc?method=SetNotDupe",
          data: "indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked"),
          error: function (xhr, textStatus, errorThrown) {
            // show error alert(errorThrown); 
          }
        });
        alert($(e.target:nth-child(-10)).css);
      });

<td class="dupegroup">#dupe_group_number#</td>
<td><input type="checkbox" name="UserIDList" value="#userid#" /></td>
<td><a href="#request.controlURL#individuals/?fa=viewIndiv" target="_blank">#userid</td>
<td>#lastname#</td> 
<td>#firstname#</td> 
<td>#nickname#</td>
<td>#companyname#</td> 
<td>#address1#</td>
<td>#zipcode#</td>
<td>#state#</td>
<td>client</td>    
<td align="center"><input class="notdupe" type="checkbox" name="indivID" value="#userid#" checked /></td>
你可以试试

$('.notdupe').live('click', function (e) {
        //alert("indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked"));
        $.ajax({
          type: "POST",
          url: "cfc/basic.cfc?method=SetNotDupe",
          data: "indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked"),
          error: function (xhr, textStatus, errorThrown) {
            // show error alert(errorThrown); 
          }
        });
        alert($(this).closest('tr').find('td:first').text());
      });
你可以试试

$('.notdupe').live('click', function (e) {
        //alert("indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked"));
        $.ajax({
          type: "POST",
          url: "cfc/basic.cfc?method=SetNotDupe",
          data: "indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked"),
          error: function (xhr, textStatus, errorThrown) {
            // show error alert(errorThrown); 
          }
        });
        alert($(this).closest('tr').find('td:first').text());
      });
在单击处理程序中:

$(this).closest('tr').find('td:first')
在单击处理程序中:

$(this).closest('tr').find('td:first')

这给了我复选框的值,即userID。我需要行中第一个TD的文本。这给了我复选框的值,即用户ID。我需要行中第一个TD的文本。这将在警报中为我提供[object object]。是的,因为这就是对象。您需要从该对象提取所需的数据。这将在警报中为我提供[object object]。是的,因为这就是对象。您需要从该对象提取所需的数据。$this.closest'tr'。first'td'。text给我tr的文本所有TDs.My bad;更新答案。使用“最近的”而不是“父项”在我看来更可靠,因为稍后您可能会将该复选框包装在其他一些标记中。$this.closest'tr'。first'td'。text给我tr的文本所有TDs.My bad;更新答案。使用“最近的”而不是“父项”在我看来更可靠,因为稍后您可能会将该复选框包装到其他一些标记中。耶!这就成功了$firstTD=$this.parent.sibbines.first警报$firstTD.text;耶!这就成功了$firstTD=$this.parent.sibbines.first警报$firstTD.text;