Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all HTML table rows between two particular rows

I have an HTML table that has rows something like this:

<tr class='department'><td>...</td><td>...</td></tr>
<tr><td>..</td><td>..</td></tr>
<tr><td>..</td><td>..</td></tr>
<tr><td>..</td><td>..</td></tr>
<tr><td>..</td><td>..</td></tr>
<tr class='departmentTotals'><td>...</td><td>...</td></tr>

I'd like to toggle the middle four rows when the top row is clicked.

Right now I am thinking I can loop through the rows using $(this).next('tr') until I get to the departmentTotals class, but is there a simple selector for this?

like image 671
user1634700 Avatar asked Feb 19 '26 01:02

user1634700


1 Answers

You can use the nextUntil method:

$(this).nextUntil('.departmentTotals') 
like image 122
undefined Avatar answered Feb 20 '26 15:02

undefined



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!