Jqonfocus,onblur <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Document</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <style> .b{border:1px solid #fc0;background:#FFFFF7;} input,textarea{border:1px solid #92B0DD;background:#FAFCFD;} label{float:left;90px;padding-right:5px;text-align:right;overflow:hidden;} </style> <script> // 连锁店显示 $(function(){ $('input[type="text"],input[type="password"], textarea').focus(function(){ $(this).addClass('b'); }).blur(function(){ $(this).removeClass('b'); }); }); </script> </head> <body> <label for="username">name: </label><input type="text" name="" id="username" /><br /> <label for="password">password: </label><input type="password" name="" id="password" /><br /> <label for="textarea">textarea:</label> <textarea name="" id="textarea" cols="30" rows="10"> 运行代码