温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何正确的使用hover方法

发布时间:2021-01-06 17:02:01 来源:亿速云 阅读:253 作者:Leah 栏目:web开发

本篇文章给大家分享的是有关如何正确的使用hover方法,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

//hover,鼠标移入移出的另一种用法

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head>   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">   <title>左导航特效</title>   <style type="text/css">     * {       margin: 0px;       padding: 0px;       font-size: 12px;     }     #nav .navsBox {       width: 160px;     }     #nav .navsBox .firstNav {       height:45px;       line-height:45px;       background-color:#EBEBEB;       border-left:10px solid #FE705C;       padding-left:20px;       width:130px;       font-weight:bold;       cursor: pointer;     }     #nav .navsBox ul {       display:none;       list-style:none;     }     #nav .navsBox ul li {       display:block;       height:45px;       line-height:45px;       padding-left:70px;       width:90px;       background-color:#F2F2F2;       background-position:33px 7px;       background-repeat:no-repeat;     }     #nav .navsBox ul li.jedh {       background-image:url("./images/huan.gif");     }     #nav .navsBox ul li.jlbbyk {       background-image:url("./images/you.gif");     }     #nav .navsBox ul li.jwljb {       background-image:url("./images/gouwu.gif");     }     #nav .navsBox ul li.mrljb {       background-image:url("./images/meiri.gif");     }     #nav .navsBox ul li.vipjtj {       background-image:url("./images/zhe.gif");     }     #nav .navsBox ul li.onbg {       background-color:#F9DBD1;     }     #nav .navsBox ul li a {       color:#000;       text-decoration:none;     }   </style>   <script src="js/jquery-1.11.3.min.js"></script>   <script>     $(function () {       $(".firstNav").click(function () {         var $ul= $(this).next();        if($ul.is(":visible")){          $ul.hide();        }else{          $ul.show();          $ul.children().hover(function () {            $(this).addClass("onbg");          },function () {            $(this).removeClass("onbg")          })        }       })     })   </script> </head> <body> <div id="nav">   <div class="navsBox">     <div class="firstNav">购物特权</div>     <ul>       <li class="jedh"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >全额兑换</a></li>       <li class="jlbbyk"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >俱乐部包邮卡</a></li>       <li class="jwljb"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >购物领金币</a></li>       <li class="mrljb"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >每日领金币</a></li>       <li class="vipjtj"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >VIP阶梯价</a></li>     </ul>   </div> </div> </body> </html>

以上就是如何正确的使用hover方法,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI