Bug Tracker

Modify

Ticket #2610 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

"return false" doesn't work

Reported by: telega Owned by:
Priority: major Milestone: 1.2.4
Component: event Version: 1.2.3
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 5 years ago by scott.gonzal

  • Status changed from new to closed
  • Resolution set to invalid

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.