I have a table where clicking a link should show ‘subrows’ that belong to the data in the row clicked.
Since the subrows number may vary from 0 to n I think I should calculate the number of subrows by the .val method, is this right? So the value should be the number of invisble rows with class name ‘affiliated’ until the next tr without a class name. How can I do this?
I made some attempts but I’m pretty new to jQuery.
I thought something like this to calculate the number of tr.affiliated:
var affiliatednumber = $(this).find("tr.affiliated").val().stop();
http://jsfiddle.net/6t6QT/2/
Your use of
.valand.stopdon’t make sense, and you are not using an input but ana. I used.nextUntilsince the rows will be grouped together; just find the closest parent row of thea(this is the “master” row) and use.nextUntilto find its affiliated rows — next until the other master row. It would also help if the master rows had their own class.