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

不言
Release: 2018-05-08 14:47:48
Original
2252 people have browsed it

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

这是会跳到页首的 这个不会跳动
Copy after login

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!

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