The difference between ‘return false;’ and ‘e.preventDefault();’

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.
13 Responses
  1. John Leverage says:

    Dude are you new to web development?
    return false is one of the oldest sentences in programming.
    god bless all of you “web developers” who dont know a thing about porgramming.

  2. Tim Wright says:

    e.preventDefault(); can actually be used to create drag & drop interfaces on touch screen devices to prevent the default scroll or zoom behavior. It’s pretty nice.

  3. Gary Storey says:

    This might be a little overkill but to play it safe maybe try this:

    $("a").click(function(e) {
    try {
    e.preventDefault();
    //do stuff here
    return false;
    } catch(err) {
    return false;
    }

  4. Skwal says:

    Very useful ! Thanks. I’m gonna use e.preventDefault() a lot more now :)

  5. Skilldrick says:

    Handy tip, cheers Chris :)

  6. Jay says:

    Nice. Now that I’ve learned something for the day, I’m going back to sleep. :)

  7. Mark says:

    My favorite example of this to show off is something like this:


    $("a.togglePanel").click(function(){
    //do something to toggle a panel
    return false;// the Google Analytics tracker below won't get called
    // e.preventDefault(); will be best here to allow the other method below to run
    });

    // track all link clicks w/ the GA helper
    $("a").click(function(){
    googleAnalyticsHelper( window.title, $(this).href() );
    });

  8. Jordan Walker says:

    Never knew that, thanks for the information.

  9. Abraão Coelho says:

    I was wondering about that just the other day!! I was using return false; almost always and never knew the difference between them.

  10. shorty42 says:

    At least I found it. The correct way return false works is (jQuery):

    function() {
    return false;
    }

    // IS EQUAL TO

    function(e) {
    e.preventDefault();
    e.stopImmediatePropagation();
    }

  11. LANCE says:


    Medicamentspot.com. Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. Low price pills. Order pills online

    Buy:Cialis.Viagra Super Force.Viagra Super Active+.Propecia.Zithromax.Cialis Super Active+.Super Active ED Pack.Viagra.Tramadol.Viagra Soft Tabs.Levitra.Cialis Soft Tabs.Maxaman.Soma.Viagra Professional.VPXL.Cialis Professional….

  12. ERIC says:


    MedicamentSpot.com. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Best quality drugs. No prescription drugs. Order drugs online

    Buy:Cialis.Cialis Professional.Soma.Super Active ED Pack.Levitra.Cialis Soft Tabs.Viagra.Viagra Super Force.Viagra Super Active+.VPXL.Tramadol.Viagra Soft Tabs.Zithromax.Cialis Super Active+.Propecia.Viagra Professional.Maxaman….

  13. CHARLES says:


    NEW FASHION store. Original designers collection at low prices!!! 20 % TO 70 % OFF. END OF SEASON SALE!!!

    BUY FASHION. TOP BRANDS: GUCCI, DOLCE&GABBANA, BURBERRY, DIESEL, ICEBERG, ROBERTO CAVALLI, EMPORIO ARMANI, VERSACE…