Implementation result: When the input part of the form is focused, the input format is changed to a CSS style (get and lose focus change style)
Html:
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <Linktype= "Text/css"href= "01.css"rel= "stylesheet"/> <Scripttype= "Text/javascript"src= "Jquery.js"></Script> </Head> <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= "Password">Password:</label> <inputID= "Password"type= "Password"/> </Div> <Div> <label for= "MSG">More information:</label> <textareaID= "MSG"></textarea> </Div> </fieldset> </form> <Scripttype= "Text/javascript"> $(function(){ $("input"). Focus (function(){ $( This). addclass ("Focus"); }). blur (function(){ $( This). Removeclass ("Focus"); }) }) </Script> </Body></HTML>
Css:
. Focus { border: 1px solid red; background: red;}
jquery--form Applications (1)