[英]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 我有不同内容的选项卡,如果验证失败,将添加特定的div标签
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 这将在选项卡内部非常深入,所以我只想获取最外层的祖先,这是具有特定名称的td
I tried to use prevUntil,parentsUntil but no luck 我尝试使用prevUntil,parentsUntil但没有运气
I just want to get the previous ancestor until i found the td with particular class 我只想得到以前的祖先,直到我找到特定班级的TD
Kindly throw some light 请丢点光
Regards Sathish 关于Sathish
For getting elements in ancestor level use closest()
. 为了获得祖先级别的元素,请使用
closest()
。 If you want all the ancestor levels then use parents()
. 如果您希望所有祖先级别,请使用
parents()
。
For the difference between methods refer : closest()
vs parents()
对于方法之间的差异,请参考:
closest()
与parents()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.