Hoe tabelcellen op een rij tellen met JQuery?

I have an image gallery with say 39 number of images.
Two buttons prev and next and in the middle a counter.
Images are inside a table and 6 of images are shown.
When the user presses next button 6 visible images go up and 6 others show.
I want to count number of visible images.
Example 6/39 when next is pressed there should be 12/39.
If i do +6 on every click sometimes the last tr has less than 6 images
and when the counter goes +6 it surpasses the number of all images. So i need to now the index of current tr being showed.
Then i need to count the td's of that tr and put this number in the counter and increment.

(mijn Engels spijt me heel erg :().


1 antwoord

in de veronderstelling dat uw tabel id "mytable" heeft, kunt u gebruiken

$( "#mytable tr td" ).length

maar, stel dat je toegang wilt tot rij 2, dan gebruik je

$( "#mytable tr:nth-child(2) td" ).length

maar als u de "td" 's van de zichtbare rij wilt tellen, gebruik dan

$( "#mytable tr:visible td" ).length