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!
En esta página del sitio puede ver el video en línea Prevent Default Explained in JavaScript | e.preventDefault() - Tutorial For Beginners de Duración hora minuto segunda en buena calidad , que subió el usuario dcode 06 abril 2018, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 59,452 veces y le gustó 1.4 mil a los espectadores. Disfruta viendo!