jquery 简单导航实现代码


复制代码 代码如下:

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("li").hover(function(){
$(this).addClass("ho");
},
function(){
$(this).removeClass("ho");
});
$("li").click(function(){
$(this).removeClass("ho").addClass("xiaoshi").siblings().removeClass("xiaoshi");
});
})
</script>
<style type="text/css">
li{background-color:#099; float:left; width:50px; height:25px; margin-left:1px; list-style:none;}
.xiaoshi{background-color:#FF0;}
.ho{background-color:#F00;}
</style>
</head>
<body>
<div>
<ul>
<li>我第1</li>
<li>我第2</li>
<li>我第3</li>
<li>我第4</li>
<li>我第5</li>
<li>我第6</li>
</ul>
</div>
</body>
复制代码 代码如下:
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("li").hover(function(){
$(this).addClass("ho");
},
function(){
$(this).removeClass("ho");
});
$("li").click(function(){
$(this).removeClass("ho").addClass("xiaoshi").siblings().removeClass("xiaoshi");
});
})
</script>
<style type="text/css">
li{background-color:#099; float:left; width:50px; height:25px; margin-left:1px; list-style:none;}
.xiaoshi{background-color:#FF0;}
.ho{background-color:#F00;}
</style>
</head>
<body>
<div>
<ul>
<li>我第1</li>
<li>我第2</li>
<li>我第3</li>
<li>我第4</li>
<li>我第5</li>
<li>我第6</li>
</ul>
</div>
</body>

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3