When you do a page, if you want to do nothing after clicking a link, or respond to the click to complete other tasks, you can set its property href = "#", however, this may cause a problem: when the page has a scroll bar, clicking it will return to the top of the page, or jump to the place where the configured anchor is located. The user experience is poor.
The common usage is:
Copy codeThe Code is as follows:
<A href = "javascript: void (0)"> Click here to see the effect. </a>
In fact, clicking here will not happen. The javascript: void (0); format is a javascript pseudo protocol, which means that this link does not jump to any place.
Javascript: void (0) is used in the following forms:
Copy codeThe Code is as follows:
// Do not do anything after you click the link
<A href = "javascript: void (0);"> test </a>
<A href = "javascript:;"> test </a>
<A href = "####"> test </a> // use 2 to 4 #. For details, see "####", you can also use "# all" and other
Copy codeThe Code is as follows:
// Click the link to respond to user-defined click events
<A href = "javascript: void (0)" onclick = "doSomething ()"> test </a>