I have a table. The table has some set of rows, each set containing 3 specific rows, and repeated downwards.
I want to have a variable i which should be incremented for each row (<tr>) having class="nm" or for each cell (<td>) having class="zxcv". The incremented result value i may be alerted finally.
How can I do this using JavaScript with / without jQuery?
You can see my JS Fiddle here.
If you just want to get a count of
<tr class="nm">and<td class="zxcv">, using jQuery, do this:EDIT:
To loop through each element, do this: