Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7913401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:50:05+00:00 2026-06-03T13:50:05+00:00

Here is a jsfiddle using POJS showing that return false; doesn’t stop the event’s

  • 0

Here is a jsfiddle using POJS showing that return false; doesn’t stop the event’s propagation: http://jsfiddle.net/Ralt/Lz2Pw/

Here is another using jQuery showing that return false; does stop the event’s propagation: http://jsfiddle.net/Ralt/D5Mtg/

Edit: The one explaining to me why jQuery does this – differing from the original behavior intentionally – (and where in the code) gets the answer.

Here is the code (long, but very easy to read):

  • HTML for both versions:

    <div id="parent1">
        <div id="child1"><a href="#" id="a1">child1</a></div>
    </div>
    
    <div id="parent2">
        <div id="child2"><a href="#" id="a2">child2</a></div>
    </div>
    
    <div id="parent3">
        <div id="child3"><a href="#" id="a3">child3</a></div>
    </div>
    
  • POJS:

    document.getElementById( 'child1' ).onclick = function( e ) {
        console.log( 'child1' );
        e.preventDefault();
    };
    
    document.getElementById( 'parent1' ).onclick = function( e ) {
        console.log( 'parent1' );
    };
    
    document.getElementById( 'child2' ).onclick = function( e ) {
        console.log( 'child2' );
        return false;
    };
    
    document.getElementById( 'parent2' ).onclick = function( e ) {
        console.log( 'parent2' );
    };
    
    document.getElementById( 'child3' ).onclick = function( e ) {
        console.log( 'child3' );
        e.stopPropagation();
    };
    
    document.getElementById( 'parent3' ).onclick = function( e ) {
        console.log( 'parent3' );
    };
    
  • jQuery version:

    $( '#child1' ).click( function( e ) {
        console.log( 'child1' );
        e.preventDefault();
    });
    
    $( '#parent1' ).click( function( e ) {
        console.log( 'parent1' );
    });
    
    $( '#child2' ).click( function( e ) {
        console.log( 'child2' );
        return false;
    });
    
    $( '#parent2' ).click( function( e ) {
        console.log( 'parent2' );
    });
    
    $( '#child3' ).click( function( e ) {
        console.log( 'child3' );
        e.stopPropagation();
    });
    
    $( '#parent3' ).click( function( e ) {
        console.log( 'parent3' );
    });
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:50:08+00:00Added an answer on June 3, 2026 at 1:50 pm

    On line 3331 of version 1.7.1, in jQuery.event.dispatch:

    ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
             .apply( matched.elem, args );
    
    if ( ret !== undefined ) {
        event.result = ret;
        if ( ret === false ) {
            event.preventDefault();
            event.stopPropagation();
        }
    }
    

    A lot of packaging has happened before this line, but basically, it runs the handler function (either a raw function, or the handler memeber function of a handlerObject) using apply. If the result of that call is false, it does preventDefault and stopPropagation.

    This is mentioned in the documentation for on():

    Returning false from an event handler will automatically call event.stopPropagation() and event.preventDefault().

    As for why they did it? I don’t know, as I’m not not the jQuery design team, but I assume it’s just because return false is a lot quicker to type than event.preventDefault(); event.stopPropagation();. (And if jQuery isn’t about making sure you have less to type, I’m not sure what it’s about.)

    I don’t believe the return value of an event handler is ever actually used anywhere in POJS (someone correct if that’s wrong!). Thus, jQuery can safely have a return statement cause side effects in a handler (since returning false in a POJS handler is meaningless, no POJS functionality is harmed).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code: http://jsfiddle.net/bfQMD/11/ Im using flip pluging and how to change opacity.
I'm using simple jcarousel here is ther code: http://jsfiddle.net/w6fLA/ I'm trying to show div
I have a jsFiddle here : http://jsfiddle.net/ZXDYS/22/ I am creating Blogger post summaries using
i have this script found here http://jsfiddle.net/g4txt/ i am using this carousel http://www.thomaslanciaux.pro/jquery/jquery_carousel.htm the
I've reproduced the problem here: http://jsfiddle.net/Rc52x/5/ If you click on Click here! while using
Fiddle here: http://jsfiddle.net/emJcx/1/ I have a drop down menu that is a simple show
My issue can be seen here - http://jsfiddle.net/aBSyH/3/ I'm using cufon text replacement and
You can see the issue here: http://jsfiddle.net/qQ6ws/36/ I am using shift to toggle my
Hi iam using this code here http://jsfiddle.net/bryanjamesross/pyNJ9/ I segregated the whole code in one
Got stuck here: http://jsfiddle.net/UFkg8/ Right now the animation is top-down. What do I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.