Check the above html page. If you click on “Disabled Link Google“, it won’t navigate to google.com but if you click on “Enabled Link Google“, it will navigate to google.com as we have disabled the first link.
Here’ how you can achieve this. During page load, disabled attribute is added to link and when clicked on particular link, preventDefault method is called.
Useful in below scenarios,
(1) when there are page links on the page, that should not be clickable until page loading is complete otherwise it leads to unexpected behavior So better choice will be to disable the links until page loads and make it clickable once the page loading is complete.
To make the disabled link enabled, below line of code to remove disabled attribute is needed.
(2) Also to stop unauthorized users from accessing some links, we can make it unclickable.