jQuery test if element1 is child of element2
Posted
by Jake
on Stack Overflow
See other posts from Stack Overflow
or by Jake
Published on 2010-03-08T01:36:49Z
Indexed on
2010/03/08
1:40 UTC
Read the original article
Hit count: 333
jQuery
Does anyone know a good way to test if one element, stored in a var, is the child of another, also stored in a var?
I don't need element1.isChildOf('selector')
, that's easy.
I need element1.isChildOf(element2)
element2.find(element1).size() > 0
Does not seem to work.
I don't want to have to write a plugin the uses .each
to test each child if I can avoid it.
© Stack Overflow or respective owner