Search code examples
javascriptnodesyui3descendant

loop over all descendants yui3 / javascript


I am trying to determine if a click occurs inside of a certain node. My idea for doing this is to take the node and loop over all of its descendants, testing if each node is the click events target.

I'm not sure what the best way to get all the descendants of a specified node is in YUI3. I am open to doing it in just plain JS if it's to complicated in yui3. I'm also open to another approach if anyone has a better way of doing this.

Thanks in advance for the help.


Solution

  • var isChild = wrapperNode.contains(targetNode);

    http://developer.yahoo.com/yui/3/api/Node.html#method_contains