代码如下,保存到html文件打开:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jquery实现tab切换-柯乐义</title>
<style type="text/css">
/* CSS Document 全局*/
*{padding:0;margin:0;}
html{border:0;width:100%;}
body{font-family:Arail,"宋体",verdana;font-size:12px;line-height:1.5em;color:#666; }
img{border:none;}input,select{vertical-align:middle; margin-right:2px;}
ol,ul,li {list-style-image:none;list-style-position:outside;list-style-type:none;margin:0;padding:0;}
ol, ul {list-style:none outside none;}
em{font-style:normal;}
a{text-decoration:none;color:#666;}
a:hover,a:active{text-decoration:underline;color:#41ABCE;}
a:visited{color:#666;}
h1{font-size:16px;}h2,h3,h4{font-size:13px;}h5,h6{font-size:12px;}
.left{ float:left;}
.right{float:right;}
.clear{ clear:both; }
.Wrap{margin:0 auto 0;overflow:hidden;width:960px;}
/*End 全局*/ .seleListCont
{
clear:both;
border-top:1px solid #39B3DA;
padding-top:10px;
width:200px;
} .seleList { }
.seleList li {
float:left;
line-height:22px;
}
.seleList li a {
line-height:22px;
padding:0 10px;
}
.seleList li.hover {
background:none repeat scroll 0 0 #FFFFFF;
border-left:1px solid #39B3DA;
border-right:1px solid #39B3DA;
border-top:1px solid #39B3DA;
bottom:-1px;
margin-left:5px;
position:relative;
}
</style>
</head> <script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript"> // JavaScript Document
/*******************************************************************************
* 标题: TAB 选项
*******************************************************************************/ jQuery(function($) {
$("#Move ul li").mouseover(function() {
var s = $(this).parent().children().index(this); //寻找父级下子元素第几个
$(this).parent().children().removeClass("hover"); //寻找父级下子元素的hover Css样式
$(this).addClass("hover")
$(this).parent().parent().next()
.children().hide()
.eq(s).show(); //s元素显示
}); }) </script> <body>
<div style="width:200px;margin:10px auto;">
<div class="seleList" id="Move">
<ul>
<li class="hover"><a href="javascript:void(0);">jQuery</a></li>
<li><a href="javascript:void(0);">Javascript</a></li>
</ul>
</div>
<div class="seleListCont">
<ul>
<li><a href="http://keleyi.com/a/bjac/etvljevm.htm" target="_blank">jQuery实现固定底部菜单</a></li>
<li><a href="http://keleyi.com/a/bjac/ec2s9a4n.htm" target="_blank">一个jQuery ajax瀑布流的例子</a></li>
<li><a href="http://keleyi.com/keleyi/" target="_blank">keleyi菜单插件首页</a></li>
<li><a href="http://keleyi.com/a/bjac/e7hhwai7.htm" target="_blank">jQ判断子元素是否包含某标签</a></li>
<li><a href="http://keleyi.com/a/bjac/bfi2kyi5.htm" target="_blank">jQuery各种事件概述</a></li>
<li><a href="http://keleyi.com/a/bjac/xbfftiqj.htm" target="_blank">jq获取下一个元素节点</a></li>
<li><a href="http://keleyi.com/a/bjac/fcskag7j.htm" target="_blank">jquery实现a:hover效果</a></li>
<li><a href="http://keleyi.com/a/bjac/bqii05en.htm" target="_blank">jQuery拉开关闭帷幕</a></li>
<li><a href="http://keleyi.com/a/bjac/c4oc8tyo.htm" target="_blank">弹出菜单jQuery插件</a></li>
</ul>
<ul style="display: none;">
<li><a href="http://keleyi.com/a/bjac/f8t46jg7.htm" target="_blank">JavaScript闭包解析</a></li><li><a href="http://keleyi.com/a/bjac/n14duxiv.htm" target="_blank">Javascript作用域</a></li><li><a href="http://keleyi.com/a/bjac/tcxhi6x1.htm" target="_blank">深入理解JavaScript的闭包</a></li><li><a href="http://keleyi.com/a/bjac/xpcxjymm.htm" target="_blank">通俗易懂的Javascript闭包介绍</a></li><li><a href="http://keleyi.com/a/bjac/6nha88id.htm" target="_blank">关于javascript闭包的简单介绍</a></li><li><a href="http://keleyi.com/a/bjac/9a9irmcm.htm" target="_blank">javascript的switch的使用注意</a></li><li><a href="http://keleyi.com/a/bjac/vovf3t3l.htm" target="_blank">浏览器窗口大小被改变时触发的事件</a></li><li><a href="http://keleyi.com/a/bjac/2k683du4.htm" target="_blank">眼珠随着光标移动JS特效</a></li><li><a href="http://keleyi.com/a/bjac/nmixur5x.htm" target="_blank">确认关闭网页的js代码</a></li><li><a href="http://keleyi.com/a/bjac/4me5brln.htm" target="_blank">Javascript的变量作用域原理详解</a></li><li><a href="http://keleyi.com/a/bjac/dyloru9f.htm" target="_blank">js获取屏幕分辨率</a></li><li><a href="http://keleyi.com/a/bjac/4esxhwgr.htm" target="_blank">js存、取、删除cookies实例</a></li>
</ul>
</div>
</div>
</body>
</html>
04-15 09:39
查看更多