Last active
February 10, 2020 15:51
-
-
Save agrogeek/095e60fcfde72a4488ed6cf93f923f41 to your computer and use it in GitHub Desktop.
Prevent click en enlaces con JavaScript puro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Esperamos a que cargue la página */ | |
| window.onload = function() { | |
| /* Seleccionamos por target, class, etc*/ | |
| listMenu = document.querySelectorAll('[attr="value"]'); | |
| /* Recorremos listado de elementos */ | |
| for (var i = 0; i < listMenu.length; i++) { | |
| /* Prevenimos evento por defecto del elemento */ | |
| listMenu[i].addEventListener("click", function(event){ | |
| event.preventDefault() | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment