1 <HTMLxmlns= "http://www.w3.org/1999/xhtml">2 <Headrunat= "Server">3 <title></title>4 <Scriptsrc= "Scripts/jquery-1.4.1.min.js"type= "Text/javascript"></Script>5 <styletype= "Text/css">6 7 <%--IE6 does not support this method--%>8 <%--input:focus, Textarea:focus9 {Ten Border:1px solid #f00; One background:#fcc; A }--%> - - . Focus the { - Border:1px solid Gray; - background:Gray; - } + - + </style> A <Scripttype= "Text/javascript"> at - $(function () { - $(": Input"). Focus (function () { - $( This). addclass ("Focus"); - }). blur (function () { - $( This). Removeclass ("Focus"); in }); - to }); + - </Script> the </Head> * <Body> $ <formID= "Form1"runat= "Server"Method= "POST">Panax Notoginseng <Divstyle= "width:300px; border:1px solid black"> - <fieldset> the <legend>Personal basic information</legend> + <Div> A <label for= "username"> theName:</label> + <inputID= "username"type= "text" /> - </Div> $ <Div> $ <label for= "Pass"> -Password:</label> - <inputID= "Pass"type= "Password" /> the </Div> - <Div>Wuyi <label for= "MSG"> theMore information:</label> - <textareaID= "MSG"rows= "5"cols= "Ten"></textarea> Wu </Div> - </fieldset> About </Div> $ </form> - </Body> - </HTML>
View Code
:
jquery Learning Notes (5)--form fields get focus and lose focus style changes