Loop over html table and get checked checkboxes (JQuery)

后端 未结 3 1903
广开言路
广开言路 2020-12-31 02:03

I have an HTML table with a checkbox in each row.
I want to loop over the table and see if there are any checkboxes that are checked.
The following does not work: <

3条回答
  •  -上瘾入骨i
    2020-12-31 02:59

    use .filter(':has(:checkbox:checked)' ie:

    $('#mytable tr').filter(':has(:checkbox:checked)').each(function() {
     $('#out').append(this.id);
    });
    

提交回复
热议问题