当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - Need to get the value of the adjacent checkboxes

问题描述:

I click on the checkbox and I should come about all checkboxes on row, checked or not (3 checkbox).

When I click on the checkbox update_order_status(this);

function update_order_status(e){

var order_id = $(e).parents('tr').find('.order_id').html();

var status_id = $(e).parents('tr').find('.status_id').val();

$(e).parents('tr').find('input').each(function(i){

//watch all input on the page, but not row

});

}

网友答案:

Use the closest method. inside your checkbox method

function yourMethod(e){
  $(e).closest("tr").find(':checkbox').each(function(e2){
    // code
  });
}

The closest method selects the most closest dom element up the tree and stops when finding it, So it will select only the parent tr.

网友答案:

You must call checkbox parents first row, and use this instead e:

$(':checkbox').click(function(e){
    $(this).parents("tr:first").find(':checkbox').each(function(e2){
         //Required logic here
    });
});
分享给朋友:
您可能感兴趣的文章:
随机阅读: