html - JQuery iterate over table rows -


i have not used jquery in while , trying simple. knowing table id, iterate on each table row , id of each table row. tried following isn't working

$("#tableid tr" ).each(function(){       var $row = $(this);       var rowid= $row.attr('id');       console.log("rowid = ", rowid); }); 

nothing getting printed on console. doing wrong?

this works me: $("#tableid tr").each((a,b)=> console.log("rowid = ", b.id));

edit: answer equivalent , should work? i've had problems jquery , malformed html in past. run html through validator maybe , see if that's issue?

also completeness sake if anyone.e ads -- that's es6 syntax, doesn't work if browser doesn't support it. can same thing function declaration.


Comments