Tuesday, 20 August 2013

Loop over html table and get checked checkboxes (JQuery)

Loop over html table and get checked checkboxes (JQuery)

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 checked.
The following does not work:
$("#save").click( function() {
$('#mytable tr').each(function (i, row) {
var $actualrow = $(row);
checkbox=$actualrow.find('input:checked'); console.log($checkbox);
});
This prints in the console objects like:
[prevObject: jQuery.fn.jQuery.init[1], context: tr, selector:
"input:checked", constructor: function, init: function…]
per row regardless that no checkbox is checked

No comments:

Post a Comment