清水流
2017-04-17 14:09
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <script src="js/jquery-1.js"></script> <style type="text/css"> .left div, .right div { width: 350px; height: 150px; padding: 5px; margin: 5px; border: 1px solid #ccc; } p { height: 50px; border: 1px solid red; margin: 30px; } .left div { background: #bbffaa; } </style> </head> <body> <h2>.hover()方法</h2> <div class="left"> <div class="aaron1"> <p>触发hover事件</p> </div> </div> <script type="text/javascript"> // hover()方法是同时绑定 mouseenter和 mouseleave事件。 // 我们可以用它来简单地应用在 鼠标在元素上行为 $("p").hover( function(){ $(this).css("background",'red'); }, function(){ $(this).css("background",'bbffaa'); } ) </script> </body> </html>这个效果怎么鼠标放上去变颜色,移开鼠标颜色不变回去呢,哪里有问题了
你的.hover(function1,function2)第二个方法都的颜色需要加# 因为是RGB格式 没加#识别不了 所以不会变颜色
你的.hover(function1,function2)第二个方法都的颜色需要加# 因为是RGB格式 没加#识别不了 所以不会变颜色
jQuery基础(三)—事件篇
89989 学习 · 625 问题
相似问题
回答 2
回答 1
回答 3
回答 2
回答 2