Web Tools Table Maker3schools TranslateImage CompressorFavicon Icon GeneratorCrop & Resize Image
Apu
Apu January 27, 2022 › #anchor #HowTo

How to prevent the browser from opening the link specified in href?

In this article, you are going to learn How do you prevent a href using javascript?

Remove the href attribute.

The easy way to "disable" a link, you can remove its href attribute so that when someone will click on it,it will not redirect to a new page.

<a class="link" href="https://www.3schools.in">disable link</a>
Remove the href=" " attribute to prevent the link.

How to remove link from anchor tag using CSS

You can easily disable all links on a page with the help of css.

Example

Prevent a href using onclick method.

Example 2
save
listen
AI Answer
Write Your Answer
loading
back
View All