Jörg Weule said:
at<ul><li><ul><li>...</li></ul></li></ul> I got the click event on the
whole tree and want to process the event for only on one node.
How can i stop the event processing calling my function for any node at
the hirachie?
If this is really only for one node, you can call the stopPropagation()
method (standards-compliant) or set the event object's `cancelBubble'
property to `true' (MSHTML) in the event listener. However, the drawback of
this is that *no* element "upwards" in the tree will receive that event
then, which may not be wanted.
If the latter is important, or if this instead for multiple nodes at the
same nesting level, you should not do this. For then you need to stop event
progagation at every child node. This comparably inefficient approach is
propagated by, e. g., jQuery and other selector-based libraries, where you
would first select elements by a criterion (usually a `class' attribute
value) and then add an event listener to each matching element.
It is therefore better (for bubbling events like `click') to add only one
event listener to an ancestor element (here: the `ul' element) in which you
compare the event target against the object the event has bubbled up to
(e.target == this, or e.srcElement == this in MSHTML [do not use
attachEvent()]), and only perform the action for relevant event targets. In
case of remaining ambiguity, you can use e. g. the event target's `class'
attribute value as well. Be aware that text nodes can be event targets,
too.
PointedEars