编辑下面的代码:【加编码】
<html> <head> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("div").focusin(function(){ $(this).css("background-color","#FFFFCC"); }); $("div").focusout(function(){ $(this).css("background-color","#FFFFFF"); }); }); </script> </head> <body> <div style="border: 1px solid black;padding:10px;"> First name: <input type="text"><br> Last name: <input type="text"> </div> <p>Click an input field to get focus. Click outside an input field to lose focus.</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂