Pregunta

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.

¿Fue útil?

Solución

With Jquery:

$('.myClass').length

Otros consejos

You use jQuery (enter link description here)

var n = $( "myClass" ).length;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top