我想获取被点击元素的所有“siblings
”,该元素具有 '.divRe'
类,其中包含 '.divAbs'
类
http://jsbin.com/uyirim/edit#javascript,html
为什么它不起作用?
(其长度假设为“1”。)
最佳答案
来自docs :
Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
链接的唯一同级是 div
,它与选择器 .divRe .divAbs
不匹配。 $('.divRe').is('.divRe .divAbs')
返回 false
。
您想将其与 .find()
结合使用:
$(this).siblings(".divRe").find(".divAbs")
编辑:看来您真正在寻找.has
而不是.find
。看看其他答案。
关于带有子类的 jQuery sibling ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7818391/