dopmgo4707 2015-06-06 14:14
浏览 1574
已采纳

如何获取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 2015-06-06 14:27
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?