Home  >  Article  >  Web Front-end  >  The difference between html empty link href="#" and href="javascript:void(0)"

The difference between html empty link href="#" and href="javascript:void(0)"

不言
不言Original
2018-05-08 14:47:482205browse

Note that it is the difference between jumping to the top of the page. It is better to use void(0) for better user experience.

#Contains a location information
The default anchor is #top, which is the top of the web page
And javascript:void(0) only represents a dead link
This is why sometimes The page is very long. The browsing link is obviously # but it jumps to the top of the page.
But javascript:void(0) is not the case.
So it is best to use void(0) when calling the script.
You can use the following example. Test it:
Code

 
 
 
 

这里是页首.....

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

这是会跳到页首的 这个不会跳动

Tips: You can modify part of the code before running


# #

The above is the detailed content of The difference between html empty link href="#" and href="javascript:void(0)". For more information, please follow other related articles on the PHP Chinese website!

Statement:
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