The onFocus event is an event that occurs when the cursor falls into the text box.
The onBlur event is an event that occurs when the cursor loses focus.
You can write the following example
1.html
<HTML> <HEAD> <TITLE>Use onBlur event handler</TITLE> </HEAD> <BODY BGCOLOR="lavender"> <FORM name="F1"> <INPUT TYPE=text NAME=text1 value="1111ONBLUR_green" ONBLUR="(document.bgColor='green')"> <INPUT TYPE=text NAME=text2 value="2222ONBLUR_black" ONBLUR="(document.bgColor='black')"> <INPUT TYPE=text NAME=text2 value="3333ONBLUR_yellow" ONBLUR="(document.bgColor='yellow')"> <br><p><INPUT TYPE=text NAME=text3 value="4444onfocus_blue" onfocus="(document.bgColor='blue')"> <INPUT TYPE=text NAME=text4 value="5555onfocus_red" onfocus="(document.bgColor='red')"><INPUT TYPE=text NAME=text4 value="6666onfocus_orange" onfocus="(document.bgColor='orange')"></FORM> </BODY> </HTML>
There are also examples below
2.html
<!-- File description: OnFocus event--> <!-- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- <input type="text" name="test2" value="I can't turn it off once I pressed, haha" onFocus=alert("I became the input focus!")> </Form> </body> </html>The above cliché talks about the onBlur incident and the onfocus incident (js) are all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.