href="javascript:;"

1. The href attribute of the tag is used to specify the URL of the hyperlink. The value of the href attribute can be the absolute or relative URL of any valid document, including fragment identifiers and JavaScript code fragments;  

1 <a id="wrap" href="javascript:;">输入密码</a>

2. javascript: is a pseudo-protocol, other pseudo-protocols include mail: tel: file:

     javascript: means to execute a piece of code when clicked, and javascript:; means to execute nothing when clicked, so that nothing happens when clicked

1 document.getElementById('wrap').addEventListener('click' ,fumction(e){
 2     e.preventDefault();
 3     // When <a> is triggered, process business 
4 }, false );

javascript:; is to remove the default behavior of the <a> tag, and href="javascript:void(0)"; void is an operator in JavaScript, and void(0) means nothing.
3. In short, "javascript:"" is another way to nest JS code in web pages, which is similar to adding JS code through tags, but it is not recommended to use

If you click the link below, javascript will be executed: the code behind

1 <a href="javascripe:alert(22);">click here</a>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325216017&siteId=291194637