超好用的简单的jquery tab选项卡切换代码(点击切换和导航栏滑过)
实例1(点击切换):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<!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 >
< style type = "text/css" >
*{ margin:0; padding:0;}
body { font:12px/19px Arial, Helvetica, sans-serif; color:#666;}
.tab { width:240px;margin:50px;}
.tab_menu { clear:both;}
.tab_menu li { float:left; text-align:center; cursor:pointer; list-style:none; padding:1px 6px; margin-right:4px; background:#F1F1F1; border:1px solid #898989; border-bottom:none;}
.tab_menu li.hover { background:#DFDFDF;}
.tab_menu li.selected { color:#FFF; background:#6D84B4;}
.tab_box { clear:both; border:1px solid #898989; height:100px;}
.hide{display:none}
</ style >
<!-- 引入jQuery -->
< script src = "../../scripts/jquery.js" type = "text/javascript" ></ script >
< script type = "text/javascript" >
// <![CDATA[
$(function(){
var $div_li =$("div.tab_menu ul li");
$div_li.click(function(){
$(this).addClass("selected") //当前<li>元素高亮
.siblings().removeClass("selected"); //去掉其它同辈<li>元素的高亮
var index = $div_li.index(this); // 获取当前点击的<li>元素 在 全部li元素中的索引。
$("div.tab_box > div") //选取子节点。不选取子节点的话,会引起错误。如果里面还有div
.eq(index).show() //显示 <li>元素对应的<div>元素
.siblings().hide(); //隐藏其它几个同辈的<div>元素
}).hover(function(){
$(this).addClass("hover");
},function(){
$(this).removeClass("hover");
})
})
//]]>
</ script >
</ head >
< body >
< div class = "tab" >
< div class = "tab_menu" >
< ul >
< li class = "selected" >时事</ li >
< li >体育</ li >
< li >娱乐</ li >
</ ul >
</ div >
< div class = "tab_box" >
< div >时事</ div >
< div class = "hide" >体育</ div >
< div class = "hide" >娱乐</ div >
</ div >
</ div >
</ body >
</ html >
|
浏览器效果:
实例2(导航栏滑过):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
<!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=utf-8" />
< title >鼠标滑过jQuery选项卡切换</ title >
< script type = "text/javascript" src = "js/jquery.min.js" ></ script >
< style type = "text/css" >
/* case */
.case{width:960px;margin:100px auto;background:#fff;padding:15px;box-shadow:0 0 10px #ccc;}
.case .title{height:20px;border-bottom:3px solid #e7e7e7;padding-bottom:10px;}
.case .title h2{font-size:20px;font-family:"microsoft yahei";}
.case .title-list{position:relative;top:6px;}
.case .title-list li{width:146px;line-height:20px;text-align:center;float:left;display:inline;cursor:pointer}
.case .title-list li.on{color:#ff6600;font-weight:bold;}
.case .title-list span{position:absolute;top:24px;left:0px;width:146px;height:7px;border-top:3px solid #ff6600;overflow:hidden;text-align:center;}
.product{position:relative;display:none;margin-top:20px; height:auto}
.product ul{}
.product-wrap .show{display:block;}
</ style >
// <![CDATA[
<script type="text/javascript">
$(function(){
//设计案例切换
$('.title-list li').click(function(){
var liindex = $('.title-list li').index(this);
$(this).addClass('on').siblings().removeClass('on');
$('.product-wrap div.product').eq(liindex).fadeIn(10).siblings('div.product').hide();
var liWidth = $('.title-list li').width();
$('.case .title-list span').stop(false,true).animate({'left' : liindex * liWidth + 'px'},300);
});
});
</script>
//]]>
</ head >
< body >
< div class = "case" >
< div class = "title" >
< ul class = "title-list" >
< li class = "on" >LOGO</ li >
< li >宣传单</ li >
< li >画册</ li >
< span ><</ span >
</ ul >
</ div >
< div class = "product-wrap" >
<!--案例1-->
< div class = "product show" >
< ul class = "cf" >
< li class = "ml0" >
< a href = "http://www.17sucai.com" class = "imgwrap" >< img src = "images/1.jpg" ></ a >
< p class = "mt10" > < a href = "http://www.17sucai.com" >站长素材网站logo... </ a ></ p >
< p class = "pb10" >行业类别:艺术摄影,文化体育</ p >
</ li >
< li >
< a href = "http://www.17sucai.com" class = "imgwrap" >< img src = "images/1.jpg" ></ a >
< p class = "mt10" > < a href = "http://www.17sucai.com" > 深圳达文影视传媒有限公司logo... </ a ></ p >
< p class = "pb10" >行业类别:艺术摄影,文化体育</ p >
</ li >
< li >
< a href = "http://www.17sucai.com" class = "imgwrap" >< img src = "images/1.jpg" ></ a >
< p class = "mt10" > < a href = "http://www.17sucai.com" > 深圳达文影视传媒有限公司logo... </ a ></ p >
< p class = "pb10" >行业类别:艺术摄影,文化体育</ p >
</ li >
< li >
< a href = "http://www.17sucai.com" class = "imgwrap" >< img src = "images/1.jpg" ></ a >
< p class = "mt10" > < a href = "http://www.17sucai.com" > 深圳达文影视传媒有限公司logo... </ a ></ p >
< p class = "pb10" >行业类别:艺术摄影,文化体育</ p >
</ li >
</ ul >
</ div >
<!--案例2-->
< div class = "product" >
2
</ div >
<!--案例3-->
< div class = "product" >
3
</ div >
</ div >
</ div >
</ body >
</ html >
|
浏览器效果:
本文转自 小旭依然 51CTO博客,原文链接:http://blog.51cto.com/xuyran/1789219
超好用的简单的jquery tab选项卡切换代码(点击切换和导航栏滑过)相关推荐
- 漂亮的jQuery tab选项卡插件
清远大学城网(http://www.qydxc.com) tab选项卡在实际应用中几乎到处可见,像现在大型网站163,QQ,新浪,淘宝都使用了tab选项卡效果,下面我来介绍一款jQuery tab选项 ...
- 微信小程序点击tab栏切换,点击切换某个tab滚动到中间( uniapp )
微信小程序点击tab栏切换,点击某个tab滚动到中间( uniapp ) 之前写过原生js的tab栏滚动到中间,正好最近有个uniapp小程序项目中要用到tab切换滚动, 写个demo发出来 + 注意 ...
- tab选项卡简易代码
<!DOCTYPE html> <html><head><meta charset="UTF-8"><title>tab ...
- jquery实现某宝放大点击切换
html代码 <body> <div class="boss"><div class="bigimg"><img sr ...
- 微信小程序 tab选项卡,可点击,可滑动
看下效果图: <view class="swiper-tab"><view class="swiper-tab-item {{currentTab==0 ...
- 超酷的广告图片切换代码(幻灯片图片切换)
<!---###########################################################--> <style type="text/ ...
- android 纯代码选项卡,纯javascript实现tab选项卡效果代码
提示:您可以先修改部分代码再运行 买家中心 卖家中心 待处理订单(10) 待确定订单(本月购买额度17826.35元(返20元) 本年购买额度您的购买金额排第1名,奖励100元! 待处理订单(10) ...
- jquery实现tab切换加自动滚动切换
1.用插件switchTab $("#switchBox7").switchTab({defaultIndex: "1", titCell: "dt ...
- ios 系统状态栏样式修改_超简单!!! iOS设置状态栏、导航栏按钮、标题、颜色、透明度,偏移等...
原标题:超简单!!! iOS设置状态栏.导航栏按钮.标题.颜色.透明度,偏移等 1. 要实现以下这些效果都非常简单 2. 废话不多说,先看看实现效果 3. 下面告诉你我为什么说实现这些效果非常简单 比 ...
最新文章
- CVPR 2020丨UDVD:用于可变退化的统一动态卷积超分辨率网络
- 标准博客 API .BLOG APIS
- Sublime Text Package Control错误另解
- ABAP Netweaver, Hybris Commerce和SAP 云平台的登录认证
- python字符串后面添加字符串_什么是字符串?怎样在Python中添加字符串?
- 2017年网易校招题 解救小易
- 福昕风腾pdf导出为html,福昕风腾PDF套件快速指引.pdf
- android自定义View学习(一)----创建一个视图类
- java的num的数据类型_Java基础---Java数据类型
- 华为、中兴嵌入式(C)笔试题
- python网站下载_python 下载整个网站
- MySQL(六):InnoDB数据文件
- 【kali】kali2020.2安装 超级详细教程
- C++人工智能相关书籍
- HDU - 5761 Rower Bo (非常详细的解答,有轨迹图)
- Probabilistic Foot Contact Estimation by Fusing Information from Dynamics and Differential/Forward K
- windows下使用命令行运行PHP
- 2023最新网络安全书单推荐——助你从零基础入门到成为网络安全工程师到进阶首席安全官
- Elasticsearch 6 Mapping设置
- 移动端必备——手机模拟器
热门文章
- 闪退补丁_ArcGIS打开amp;闪退问题
- python抓取数据库数据封装成json_用Python将mysql数据导出成json的方法
- websocket receive方法内 有循环怎么退出_WebSocket了解一下
- java校验码的设计_Java动态验证码单线设计的两种方法
- lm358数据手册_如何阅读运放的数据手册(1)查找数据手册
- 【阿里云课程】深度学习模型设计:卷积核的设计与优化
- 全球及中国停车场建设产业十四五盈利模式与建设现状分析报告2022版
- 全球及中国本质安全校准器行业销售前景与竞争规模预测报告2022-2027年
- 全球及中国拉丝润滑剂粉末行业投资潜力及发展战略规划报告2021-2027年
- 中国溶解浆市场深度调研及投资战略决策报告2022-2028年版