编辑下面的代码:【加编码】
<html> <head> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").mouseover(function(){ $("p").css("background-color","yellow"); }); $("p").mouseout(function(){ $("p").css("background-color","lightgray"); }); $("#btn1").click(function(){ $("p").mouseover(); }); $("#btn2").click(function(){ $("p").mouseout(); }); }); </script> </head> <body> <p>Move the mouse pointer over this paragraph.</p> <button id="btn1">Trigger mouseover event</button><br> <button id="btn2">Trigger mouseout event</button> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂