Yetimwork Beyene
Yetimwork Beyene

Reputation: 2337

how do I find a particular class of the closest element?

I'm trying to find a particular class match from a closest element

     $(this).closest("tr"); 

I need to find out if this tr has a class name testlog3 from the point.

Upvotes: 1

Views: 68

Answers (2)

icktoofay
icktoofay

Reputation: 128991

Use hasClass:

if($(this).closest('tr').hasClass('testlog3')) {
    // ...

Upvotes: 2

Mottie
Mottie

Reputation: 86413

You can use the closest function as follows:

$(this).closest('tr.testlog3');

Upvotes: 2

Related Questions