When doing a page, if you want to do a link after clicking do not do anything, or respond to click and complete other things, we can use Javascript:void (0), the following is the specific use of the method, interested friends can refer to the following
When you do a page, if you want to do a link click Do not do anything, or respond to click to complete other things, you can set its properties href = "#", however, this will have a problem is that when the page has a scroll bar, click will return to the top of the page, or jump to the set anchor point where the user experience is not good.
The usual usage is:
Copy code code as follows:
<a href= "javascript:void (0)" > click here to see the effect </a>
Actually click here and nothing will happen, where the javascript:void (0); The form is a JavaScript pseudo protocol, which means that the link does not jump anywhere.
The use of javascript:void (0) is mainly in the following ways:
Copy code code as follows:
Click on the link and don't do anything
<a href= "javascript:void (0);" >test</a>
<a href= "javascript:;" >test</a>
<a href= "#" >test</a>//Use 2 to 4 #, see mostly "#", also use "#all" and other
Copy code code as follows: Click on the link to respond to user-defined click events <a href= "javascript:void (0)" onclick= "dosomething ()" >test</a>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.