O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Stopping Default Behavior

function myEventHandler(e){   ...handler code...   e.preventDefault();   return false; }

Occasionally, you might want to prohibit the browser from applying the default handler interaction for the event. For example, you might not want the browser to activate a link, or you might not want to allow a form to be reset. You can stop the default browser action by calling the event.preventDefault() method on the event object passed to the handler.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required