Cancelling default behavior


show more Cancelling default behavior provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the JavaScript: Events show less
please wait ...

Cancelling default behavior

A lot of events have default behaviors that take place when the events happen. So for example when we click on a link, the default behavior is to follow that link probably onto a website. Or when the user tries to submit a form, the default behavior is to take the form data and pass it to a form processor. You might want to stop the data from being passed to the form processor, so you can do your own validation. In order to control how an event reacts with default behavior, we use a method called prevent default. So, let's take a look at how that works. So, here I am on my form and what I want to do is add an anchor tab to all these elements.

So, I'm going to use a kung fu Sublime Text 2 technique. So, hold down the Alt key or the Option key on a Mac and click and drag it to select all these elements. And I'm going to hold down the Cmd+Shift key because I'm on a Mac and hit the right arrow. That's going to select everything from that point to the end of the line. Then I'm going t...

Cancelling default behavior
Video duration: 2m 49s 2h 11m Intermediate

Viewers:

Cancelling default behavior provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the JavaScript: Events

Subjects:
Developer Web
Software:
JavaScript
Author:
please wait ...