Skip to content

Instantly share code, notes, and snippets.

@miguelitodev
Created August 19, 2020 20:37
Show Gist options
  • Save miguelitodev/a6d71091a4a92df3e045d09eac748252 to your computer and use it in GitHub Desktop.
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
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