• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

My Monkey Do

A Log of Coding Solutions

  • Home
  • Web Hosts
  • Tools
  • About

jQuery – When to use return false or preventDefault

April 15, 2013 by Webhead

Ran into a great article that explains the differences between return false, preventDefault and stopPropagation.  Here’s a summary:

  • return false does both preventDefault and stopProgagation
  • preventDefault just stops the browser default event.
  • stopPropagation stops bubbling.

In most cases you would only want to do preventDefault.  If you stopPropagation you prevent your code from being extensible.

 

source:  http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/

Filed Under: Coding Tagged With: javascript, jquery

Primary Sidebar

Topics

apache apple block editor chrome cms css debug eCommerce embed firebug firefox git gmail goDaddy google hosting htaccess html html 5 IE crap image iPad iPhone javascript jquery linux localization mac os x ms sql mysql open source optimize php php 5.3 responsive rest api seo svg tinymce woocommerce wordpress wpengine xss yii youtube




Categories

  • Coding
  • Off the Shelf
  • Plugins
  • Random Thoughts
  • Server Stuff
  • Tools