sathishkumar
sathishkumar

Reputation: 347

JQuery ancestor td selector with particular class

I have a problem in selecting my ancestor with particular class,

I have different tabs with different contents particular div tag will be added if it gets any validation failure

 jQuery("table #sectionDisplay .ItemDetailContainerCell div").hasClass("error-label");

This will go very deep inside the tab so i just want get the outermost ancestor which is a td with particular name

I tried to use prevUntil,parentsUntil but no luck

I just want to get the previous ancestor until i found the td with particular class

Kindly throw some light

Regards Sathish

Upvotes: 1

Views: 53

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115222

For getting elements in ancestor level use closest(). If you want all the ancestor levels then use parents().

For the difference between methods refer : closest() vs parents()

Upvotes: 2

Related Questions