Bug Tracker

Opened 12 years ago

Closed 12 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>

Change History (1)

comment:1 Changed 12 years ago by scott.gonzal

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.