The first: (When the text box gets the focus, its color changes, and when it loses focus, it reverts to its original appearance)
<HTML> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/> <Scripttype= "Text/javascript"src= "Jquery-1.11.3.js"></Script> <styletype= "Text/css">Input:focus, Textarea:focus{Border:1px solid #f00;background:#fcc; } </style> <Body> <formAction="#"Method= "POST"ID= "RegForm"> <fieldset> <legend>Personal basic information</legend> <Div> <label for= "username">Name:</label> <inputID= "username"type= "text"> </Div> <Div> <label for= "Pass">Password:</label> <inputID= "Pass"type= "Password"> </Div> <Div> <label for= "MSG">More information:</label> <textareaID= "MSG"></textarea> </Div> </fieldset> </form></Body></HTML>
Just not compatible in IE
The second type of IE is compatible:
1 <HTML>2 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/>3 <Scripttype= "Text/javascript"src= "Jquery-1.11.3.js"></Script>4 <styletype= "Text/css">5 6 . Focus{7 Border:1px solid #f00;8 background:#fcc;9 }Ten </style> One <Scripttype= "Text/javascript"> A $(function(){ - $(": Input"). Focus (function(){ - $( This). addclass ("Focus") the }). blur (function(){ - $( This). Removeclass ("Focus"); - }) - }) + - </Script> + <Body> A <formAction="#"Method= "POST"ID= "RegForm"> at <fieldset> - <legend>Personal basic information</legend> - <Div> - <label for= "username">Name:</label> - <inputID= "username"type= "text"> - </Div> in <Div> - <label for= "Pass">Password:</label> to <inputID= "Pass"type= "Password"> + </Div> - <Div> the <label for= "MSG">More information:</label> * <textareaID= "MSG"></textarea> $ </Div>Panax Notoginseng - </fieldset> the </form> + A </Body> the </HTML>
jquery gets and loses focus change style