문제

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.

도움이 되었습니까?

해결책

With Jquery:

$('.myClass').length

다른 팁

You use jQuery (enter link description here)

var n = $( "myClass" ).length;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top