In the work, if we want to put the link in the a tag into an empty link, we generally use two methods:
1 |
<a href= "#" target= "_blank" ></a> |
Or
1 |
<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= "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).
The difference between href= "#" and href= "javascript:void (0)"
"#" contains a location. The default anchor point is #top, which is the top of the page, and Javascript:void (0) represents only a dead link. This is why sometimes the page is very long browse the link is obviously # but the jump to the first page and javascript:void (0) This is not the case, so it's best to use void (0) when invoking a script.
"Go" href= "#" and "javascript:void (0);" The difference