Does anyone know a good way to test if one element, stored in a var, is the descendant of another, also stored in a var?
I don't need element1.isChildOf('selector'), that's easy. I need element1.isChildOf(element2)
element1.isChildOf('selector')
element1.isChildOf(element2)
element2.find(element1).size() > 0 Does not seem to work.
element2.find(element1).size() > 0
I don't want to have to write a plugin the uses .each to test each child if I can avoid it.
.each
If you're using 1.4, and are looking for a descendant rather than a child as your find() example implies, there's a has() method:
find()
has()
element2.has(element1).length > 0
2.1m questions
2.1m answers
60 comments
57.0k users