jquery tab选项卡
2014-06-19 09:36
489 查看
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>选项卡效果</title>
<script type="text/javascript" src="js/jquery-1.7b2.js"></script>
<script type="text/javascript">
$(document).ready(function(){ //页面加载时
$('.ct:gt(0)').hide();
var hwd=$('.box ul li');
/*hwd.hover(function(){ //鼠标移上去背景变化,hover事件
$(this).addClass('two')
.siblings().removeClass(); //删除兄弟节点
});*/
hwd.hover(function(){
$(this).addClass('one')//向匹配的元素添加指定的类名。
.siblings().removeClass();
var hwd_index=hwd.index(this);//搜索匹配的元素,并返回相应元素的索引值,从0开始计数。
//alert(hwd_index);
$('.ct').eq(hwd_index).show().siblings().hide();
});
});
</script>
<style>
*{ padding:0px; margin:0px;}
body{ font-size:12px; padding:100px;}
ul{ list-style-type:none;}
.box ul{ height:30px; line-height:30px;}
.box ul li{ float:left; padding:0 10px;cursor:pointer; position:relative; background:url(images/bg1.png) repeat-x; border:1px solid #dbe2e7; margin-right:5px; border-bottom:none;}
.content{ width:325px; border:1px solid #dbe2e7; padding:10px;}
* html.content{ margin-top:-1px;}
.box ul li.one{ background:#fff; }
.box ul li.two{ background:orange;}
</style>
</head>
<body>
<div class="box">
<ul>
<li class="one">菜单一</li>
<li>菜单二</li>
<li>菜单三</li>
</ul>
<div class="content">
<div class="ct">菜单一的内容</div>
<div class="ct">菜单二的内容</div>
<div class="ct">菜单三的内容</div>
</div>
</div>
</body>
</html>
效果:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>选项卡效果</title>
<script type="text/javascript" src="js/jquery-1.7b2.js"></script>
<script type="text/javascript">
$(document).ready(function(){ //页面加载时
$('.ct:gt(0)').hide();
var hwd=$('.box ul li');
/*hwd.hover(function(){ //鼠标移上去背景变化,hover事件
$(this).addClass('two')
.siblings().removeClass(); //删除兄弟节点
});*/
hwd.hover(function(){
$(this).addClass('one')//向匹配的元素添加指定的类名。
.siblings().removeClass();
var hwd_index=hwd.index(this);//搜索匹配的元素,并返回相应元素的索引值,从0开始计数。
//alert(hwd_index);
$('.ct').eq(hwd_index).show().siblings().hide();
});
});
</script>
<style>
*{ padding:0px; margin:0px;}
body{ font-size:12px; padding:100px;}
ul{ list-style-type:none;}
.box ul{ height:30px; line-height:30px;}
.box ul li{ float:left; padding:0 10px;cursor:pointer; position:relative; background:url(images/bg1.png) repeat-x; border:1px solid #dbe2e7; margin-right:5px; border-bottom:none;}
.content{ width:325px; border:1px solid #dbe2e7; padding:10px;}
* html.content{ margin-top:-1px;}
.box ul li.one{ background:#fff; }
.box ul li.two{ background:orange;}
</style>
</head>
<body>
<div class="box">
<ul>
<li class="one">菜单一</li>
<li>菜单二</li>
<li>菜单三</li>
</ul>
<div class="content">
<div class="ct">菜单一的内容</div>
<div class="ct">菜单二的内容</div>
<div class="ct">菜单三的内容</div>
</div>
</div>
</body>
</html>
效果:
相关文章推荐
- jquery tab 选项卡
- jquery实现的非常简单实用带有渐变切换效果的tab选项卡
- tab选项卡-jQuery
- 便捷的jquery TAB选项卡
- 深入浅出jquery中tab选项卡之常用方法siblings用法
- 实用的Jquery选项卡TAB示例代码
- 【锋利的JQuery-学习笔记】Tab选项卡的实现
- jquery Tab 选项卡通用函数
- jquery简单实现tab选项卡效果
- 动感效果的TAB选项卡jquery 插件
- jQuery Tab选项卡切换代码
- 动感效果的TAB选项卡 jquery 插件
- 二款实例Jquery tab选项卡效果代码
- jquery tab选项卡切换实例
- 做ecshop选项卡,但由于ecshop与jquery冲突原因,不想用jquery,所以自己做了个tab卡
- JQuery Tab选项卡效果代码改进版
- jquery写的一个TabControl类,动态创建选项卡切换Tab
- jQuery Tab选项卡切换代码
- 一款基于jQuery的热点新闻Tab选项卡插件
- jquery插件tytabs.jquery.min.js实现渐变TAB选项卡效果