dopmgo4707
dopmgo4707
2015-06-06 14:14

如何获取html <table>的<tr>中的所有值

I want to get all values of td when I click the checkbox which is fourth coloumn. Also I want to get the smallest among ID and Optional ID

<table><form method='GET'>
<tr>
<th>Name</th>
<th>ID</th>
<th>Optional ID</th>
<th>Approved</th>
</tr>
<tr>
<td>Sumit</td>
<td>4</td>
<td><input type='text' name='txt`[]' /></td>
<td><input type='checkbox' name='chk[]' /></td>
</tr>`
<tr>
<td>Harsh</td>
<td>3</td>
<td><input type='text' name='txt`[]' /></td>
<td><input type='checkbox' name='chk[]' /></td>
</tr>`
<tr><td colspan=4><input type='submit' name='sub1' /></td></tr>    
</form>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • doufan6544 doufan6544 6年前

    I think this is what you're looking for:

    function Start() {
    
        $('#SubmitBtn').click(function () {
    
            $('#TheTable').find('tr').each(function () {
    
                if ($(this).find('input').eq(1).is(':checked') === true) {
    
                    alert($(this).find('input').val());
                }
    
            });
        });
    }
    
    $(Start);
    

    There's a jsFiddle here

    点赞 评论 复制链接分享

为你推荐