Directory:
- 1href= "#" Method
- 2href= "javascript:void (0);" Method
- 3#与javascript: The difference between void (0)
Overview: At work, if we want to put the link in the a tag into an empty link, we generally use two methods: <a href= "#" target= "_blank" ></a><a href= "# #" target= "_blank" ></a>
or <a href= "javascript:void (0);" target= "_blank" ></a>
The above two methods many people think is the method of empty link, but the two methods are different, what is the difference? Let's talk about it today. Href= "#" method: In fact, is also the meaning of empty connection, but after the click will automatically jump to the top of the page, because this method is equivalent to click on an anchor, but this anchor is not written ID, so the default jump to the top of the page. Href= "# # #" method: In fact, is also the meaning of empty connection, but after the click will not jump to the top of the page. href= "javascript:void (0);" Method: Void is an operator that specifies to evaluate an expression but does not return a value. If you write 0 (void (0)) in void, nothing is done and an empty link is formed. #与javascript: void (0) differs: So, #与javascript: the difference between void (0) is also obvious, #方法会跳转到页面的顶部, and a # appears after the page URL, and the Javascript:void (0) method does not, So if it is an empty connection, it is recommended to Javascript:void (0). Original link http://www.uw3c.com/cssviews/css12.html
The difference between href= "#" and javascript:void (0)