1.
当鼠标指针悬停在上面时,改变 <p> 元素的背景颜色:
2.
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>菜鸟教程(runoob.com)</title> 6 <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"> 7 </script> 8 <script> 9 $(document).ready(function(){ 10 $("p").hover(function(){//鼠标移到 11 $("p").css("background-color","yellow"); 12 },function(){//鼠标移动走 13 $("p").css("background-color","pink"); 14 }); 15 }); 16 </script> 17 </head> 18 <body> 19 20 <p>鼠标移动到该段落。</p> 21 22 </body> 23 </html>