user1227914
user1227914

Reputation: 3514

jquery targeting next ID

I have a table colspan that I'd like to add a class to with jQuery:

<td colspan="3" id="colspan-123">

And I tried with:

$(this).closest(\'#colspan-123\').next(\'#colspan-123\').toggleClass("row-notop");

But that's not working. What am I doing wrong?

Upvotes: 0

Views: 28

Answers (1)

jcuenod
jcuenod

Reputation: 58395

I am one of the upvotes for "ids must be unique". They must!

However you could use this selector and add a class:

$("td[colspan=3]").addClass("row-notop");

Upvotes: 1

Related Questions