Jquery navigation component jquery mouse over the color change effect example

  • 2020-03-30 00:43:39
  • OfStack


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title> Mouse over the navigation   The current LI discoloration   In the current position </title>
<style type="text/css">
ul,li{list-style:none;}
#nav li{display:inline-block;margin:0 5px;background:#ccc;padding:0 10px; line-height:24px;font-size:12px;float:left;}
#nav li.h_nav_over{background:red;color:#fff;}
#nav li.h_nav_over a{color:#fff;}
a{text-decoration:none;}
</style>
<script type="text/javascript" src="/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(function(){
$("#nav>ul>li").mouseover(function(){
        $("#nav>ul>li").each(function(i){
            $(this).removeClass("h_nav_over");
        });
        $(this).addClass("h_nav_over");
    }).mouseout(function(){
        $(this).addClass("h_nav_over");
    });
});
</script>
</head>
<body>
<div id="nav">
     <ul>
        <li><a  href="//www.jb51.net" > Home page </a></li><li><a  href="//www.jb51.net/a/" > Brand business opportunities </a></li>
        <li><a  href="//www.jb51.net/" > High-quality goods business </a></li><li><a  href="//www.jb51.net/" > The latest business opportunities </a></li>
        <li><a  href="//www.jb51.net/" > Investment review meeting </a></li><li><a  href="//www.jb51.net/" > Online communication area </a></li>
     </ul>
</div>
</body>
</html>


Related articles: