Home > Web Front-end > JS Tutorial > body text

How to hide herf in javascript

藏色散人
Release: 2021-06-15 10:30:13
Original
2368 people have browsed it

How to hide herf in javascript: first add a link in html; then add an id to the link; then add a data-link attribute and remove the original href attribute; finally use locacion.href Just let the page jump.

How to hide herf in javascript

The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.

How to hide herf in javascript?

We add a link in html, which has the href link attribute.

How to hide herf in javascript

After running the page, we put the mouse over the link and you can see that the link address will be seen in the browser.

How to hide herf in javascript

To hide this link information, we can add an id to the link. Adding the id is convenient for adding click events to it. Then add a data-link attribute, the attribute value is the value of the href link, and remove the original href attribute.

How to hide herf in javascript

Then add a click event for this link.

How to hide herf in javascript

On the event function, obtain the value of data-link through the data method.

How to hide herf in javascript

Then use locacion.href to jump the page.

How to hide herf in javascript

Run the page. Now when we put the mouse on the link, the link href content will no longer be displayed. But after we click this link, we will also jump to the original page.

How to hide herf in javascript

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of How to hide herf in javascript. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template