Prevent Default Explained in JavaScript | e.preventDefault() - Tutorial For Beginners

Veröffentlicht am: 06 April 2018
auf dem Kanal: dcode
59,452
1.4k

The Event.preventDefault method in JavaScript allows you to prevent the default behaviour from occurring when an event gets fired off - this is going to change depending on the element and context. For example, when dealing with links (anchor elements), the default behaviour would be to redirect to the URL, but with preventDefault() we are able to prevent this from happening.

In this video I take you through an example with a link to the YouTube website and how we can use preventDefault() to disable it. I also create a checkbox which enables/disables the link.

For your reference, check this out:
https://developer.mozilla.org/en-US/d...

Follow me on Twitter @dcode!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!


Auf dieser Seite können Sie das Online-Video Prevent Default Explained in JavaScript | e.preventDefault() - Tutorial For Beginners mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer dcode 06 April 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 59,452 Mal angesehen und es wurde von 1.4 tausend den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!