Search code examples
javascripthtmlonclick

Make the click on inner div not to call the outer one's onClick function


Possible Duplicate:
Prevent parent container click event from firing when hyperlink clicked

I have

<div onClick="someJScode();">
  ...
  <div></div>
  ...
</div>

I don't want someJScode() to be called when the inner div is clicked. How to do this?


Solution

  • <div onclick="event.stopPropagation();"

    This will stop click event bubbling up the DOM.

    https://developer.mozilla.org/en/docs/DOM/event.stopPropagation