简单的jquery tab切换代码
2016-03-21 11:07
603 查看
<style> /* 产品中心切换样式 */ .left_div{width:689px; overflow:hidden; float:left; position:relative;} .title{ position:absolute; left:15px; height:40px; line-height:40px; font-size:18px; z-index:100;color:#cf9100;} .title span{font-size:12px; font-family:"Microsoft YaHei";color:#999; } .product_div .tab2 .more{ height:53px; line-height:53px; margin-right:10px;} .cpzx_div{width:700px; overflow:hidden; float:left; background-color:#FFFFFF;} /*.cpzx_title{ width:711px; height:53px; line-height:53px; font-size:16px; font-family:"Microsoft YaHei";color:#333; background:url(../images/gg_03.jpg) no-repeat left; } .cpzx_title span{font-size:12px; font-family:"Microsoft YaHei";color:#999;} .cpzx_title .more{ height:53px; line-height:53px;} .cpzx_title .more a{ height:53px; line-height:53px;}*/ .product_div{width:700px; height:260px; border:1px solid #f1e7db;border-bottom:3px solid #f1e7db;} .product_div .tab2{width:700px;height:auto; overflow:hidden; } .product_div .tab2 ul.menu2{ width:570px; height:40px; background:url("../images/uy.jpg") no-repeat;padding-left:130px; border-bottom:#CCCCCC solid 1px; } .product_div .tab2 ul.menu2 li{width:70px; height:40px; line-height:40px; cursor: pointer; font-size:14px; font-family:"微软雅黑"; color:#333;cursor:pointer; float:left; text-align:center;} .product_div .tab2 ul.menu2 li.active2{width:70px; height:40px; line-height:40px; color:#bb3a27;border:1px solid #f1e7db; background-color:#FFFFFF; border-bottom-color:#FFFFFF; } .product_div .con1,.product_div #con2,.product_div .con3,.product_div .con4,.product_div .con5,.product_div .con6{ padding-top:10px; display:none; } .product_div .shuju{ height:153px; width:500px; margin:20px 7px; display:inline;} .product_div .shuju img{ margin-top:30px;} </style> <div class="tab2" id="tab2"> <span class="title">延时行情图</span> <ul class="menu2"> <li class="active2">现货白银</li> <li class="">现货铜</li> <li class="">现货铝</li> <li class="">现货镍</li> <li class="">现货钯金</li> <li class="">现货铂金</li> </ul> <div class="con1" style="display: block;"> <div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/sliver1.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/sliver2.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="clear"></div></div> <div class="con2"><div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/cu1.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/cu2.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="clear"></div></div> <div class="con3"><div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/al1.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/al2.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="clear"></div></div> <div class="con4"><div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/ni1.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/ni2.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="clear"></div> </div> <div class="con5"> <div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/palladium1.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/palladium2.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="clear"></div></div> <div class="con6"> <div class="shuju"><iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/platinum1.html" frameborder="0" width="330" scrolling="no"></iframe> </div> <div class="shuju"> <iframe id="sliver_left" height="220" src="http://www.tjpme.com/mydemo2/platinum2.html" frameborder="0" width="330" scrolling="no"></iframe></div><div class="clear"></div></div> </div> <script> $('#tab2 ul.menu2 li').click(function(){ //获得当前被点击的元素索引值 var Index = $(this).index(); //给菜单添加选择样式 $(this).addClass('active2').siblings().removeClass('active2'); //显示对应的div $('.tab2').children('div').eq(Index).show().siblings('div').hide(); }); </script>
相关文章推荐
- jquery获得location的传值 和一些滚动效果243dede
- 用jquery实现滚动浏览器滚动条加载数据(类似于腾讯微博) [复制链接]
- jquery 滚动,或点击,加载文章
- innerHTML与jquery里的html()区别介绍
- Jquery下判断Id是否存在
- jquery中的$(function(){...})什么时候执行
- jquery让div中所有的a标签的target属性为“_blank”
- jquery 实现iframe 自适应高度
- jQuery - last-child 选择所有最后一个子元素 last最后一个元素
- $jquery.ajax 访问数据库 php html 等。
- jquery 选择奇偶行。
- JQuery中$.ajax()方法参数详解
- JQuery -- this 和 $(this) 的区别
- jquery css()方法
- jquery ajax 单击修改文档
- Jquery显示和隐藏元素或设为只读(…
- jQuery ajax - ajax() 方法
- jquery 收缩框
- Html Jquery/Js控制audio总结
- jQuery操作select下拉框的text值和value值的方法