I need the correct syntax to write two loops inside each other. First one to loop over each table in an html page with no ids or classes and the second one to iterate over each table row of the table specified by the first loop in jQuery.
Here is my jQuery but its not working probably wrong syntax.
$(document).ready(function(){
$('table.rep').each(function(){
$(this + ' tr').each(function{
// change style of this tr
});
});
});
You do it like this (uses the jQuery context parameter to restrict the search for a
trelement to the table:Or alternatively, like this (uses the
findmethod to find elements that reside inside the element represented by the jQuery object you call the method on):You don’t even have to nest loops depending on what you want to do, just looping over all table rows may suffice: