Refresh the verification code as an example.
Copy codeThe Code is as follows:
<Form method = "post" name = "login" action = "">
Verification code: <input type = "text" name = "code" class = "text code"/>
</Form>
Method 1: Use the pseudo class implementation of JavaScrip
Copy codeThe Code is as follows:
Method 2: Import external files
Introduce external files between html files
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = "js/code. js"> </script>
// Set the local refresh function in the code. js file.
Function code (){
Var code = document. getElementByIdx_x_x ('code ');
Code. onclick = function (){
This. src = 'Code. php? Tm = '+ Math. random ();
};
};
In addition, if you want to add a content next to the Verification code, and then click the content verification code to refresh, you can use the following method
Copy codeThe Code is as follows:
<Form method = "post" name = "login" action = "">
Verification code: <input type = "text" name = "code" class = "text code"/>
<Span id = "update"> click to refresh the Verification Code </span>
</Form>
Method 1: Use the pseudo class implementation of JavaScrip
Copy codeThe Code is as follows:
<span id = "update" onclick = "javascript: code. src = 'Code. php? Tm = '+ Math. random () "> </span>
Method 2: Import external files
Introduce external files between html files
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = "js/code. js"> </script>
// Set the local refresh function in the code. js file.
Function code (){
Var code = document. getElementByIdx_x_x ('code ');
Var update = document. getElementByIdx_x_x ('update ');
Update. onclick = function (){
Code. src = 'Code. php? Tm = '+ Math. random ();
};
};