Opened 15 years ago
Closed 15 years ago
#2610 closed bug (invalid)
"return false" doesn't work
Reported by: | telega | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.2.4 |
Component: | event | Version: | 1.2.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I have 2 onclick handlers assigned to a document, each one returning false. But clicking on the document causes both handlers to be invoked disregarding "return false". Happens in all the browsers (FF 3, Opera 9, IE 7). Tried "click" and "mousedown" events, both have the same behavior.
<script src="jquery-1.2.3.js"></script> <script> $(document).ready(function() { $(document).bind("click", "data1", function() { alert('click1'); return false; }); $(document).bind("click", "data2", function() { alert('click2'); return false; }); }); </script>
Note: See
TracTickets for help on using
tickets.
Straight from the docs:
To stop both default action and event bubbling, your handler has to return false. Note that this will prevent handlers on parent elements from running but not other jQuery handlers on the same element.