2010-01-02 126 views
0

我得到所有使用此代码的html表格中的复选框,我需要从当前复选框中查找表中的当前行。如何在html表中获取当前输入控件的行像文本框

  var checkboxes = $("form :checkbox"); 
      for (i = 0; i <= checkboxes.length; i++) { 

       var checkbox = checkboxes[i]; 

       ///need to get current row in html table here 
      } 
+0

类型。这个问题已被修复 – leora 2010-01-02 14:40:16

回答

1
var checkboxes = $("form :checkbox"); 
    for (i = 0; i <= checkboxes.length; i++) { 

     var checkbox = checkboxes[i]; 

     var rowIndex = $(checkbox).closest('tr')[0].rowIndex; 
    } 

应该这样做

+0

你让我走向正确的方向。我更新了你的答案,最终的解决方案 – leora 2010-01-02 14:39:39

+0

只是略微改变,以使用索引,而不是'get()'调用(少一个函数调用)。 – 2010-01-02 14:41:45

相关问题