How to get attribute flag value

I want to get the value of the attribute value of the flags. my code gives me undefined

$('#mytable').find('tr').each(function () { var row = $(this); if ( row.find('input[type="checkbox"]').is(':checked') ) { alert( $(this).attr("b_partner_id") ); } }); 
+4
source share
1 answer

this refers to the tr element in the if block, since your b_partner_id attribute is b_partner_id present in the tr element, which you get undefined .

Instead, you need to get the attribute value using the checkbox link

 $('#mytable').find('tr').each(function () { var row = $(this), $check = row.find('input[type="checkbox"]'); if ($check.is(':checked')) { alert($check.attr("b_partner_id")); } }); 
+5
source

All Articles