Created
August 19, 2020 20:37
-
-
Save miguelitodev/a6d71091a4a92df3e045d09eac748252 to your computer and use it in GitHub Desktop.
Adicionar um valor a um href vazio para que o link não recarregue a tela, JQuery & JavaScript
This file contains 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
const tagA = document.querySelectorAll("a"); | |
$(window).on("load", function () { | |
for (i = 0; i <= tagA.length; i++) { | |
if (tagA[i].href === document.URL) { | |
tagA[i].href = "javascript:void(0)"; | |
} else { | |
return; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment