Question

I am creating and filling an HTML table using PHP. During this each TR gets a certain class.

Is there a way I can count how many elements have this class so that I can echo the number somewhere on the page on page load ? (Other TRs would have different or no classes.)

Example TR:

<tr class="myClass"></tr>

Many thanks in advance, Mike.

Était-ce utile?

La solution

With Jquery:

$('.myClass').length

Autres conseils

You use jQuery (enter link description here)

var n = $( "myClass" ).length;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top