Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to enable and disable href in javascript

// Example link
// <a id="my-link" href="https://codegrepper.com">Text</a>
var a = document.getElementById("my-link");
a.originalLink = a.href;
// disable link
a.href = 'javascript:void(0)';
// re-enable link
a.href = a.originalLink;
 
PREVIOUS NEXT
Tagged: #enable #disable #href #javascript
ADD COMMENT
Topic
Name
5+2 =