Refresh the verification code as an example.
CopyCode The 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 code The Code is as follows:
Method 2: Import external files
Introduce external files between HTML files
Copy code The 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 code The 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 code The 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 code The 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 ();
};
};