教程集 www.jiaochengji.com
教程集 >  脚本编程  >  javascript  >  正文 js tab选项卡效果代码

js tab选项卡效果代码

发布时间:2016-11-26   编辑:jiaochengji.com
教程集为您提供js tab选项卡效果代码等资源,欢迎您收藏本站,我们将为您提供最新的js tab选项卡效果代码资源
在js中js tab选项卡实现很简单,我们只要设置li的ID与对应的隐藏内容的后缀ID一样就可以实现切换了。
提示:您可以先修改部分代码再运行

<textarea name="runcool" rows="28" cols="75" > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf8"> <title>常用tab切换</title> <style type="text/css"> #box{width:500px;font-size:12px} #box ul{margin:0;padding:0;list-style:none} #box #tab{height:25px;padding-left:10px;border-bottom:1px solid #AACBEE} #box #tab li{width:80px;height:18px;padding-top:7px;margin-right:10px;text-align:center;float:left;background:#F3F8FD;cursor:pointer} #box #tab li.on{width:78px;height:19px;padding-top:5px;border:1px solid #AACBEE;border-bottom:none;color:#00f;background:#E8F2F7;position:relative;top:1px} #box #tab_con{border:1px solid #AACBEE;border-top:none;padding:20px} #box #tab_con li{display:none} #box #tab_con #tab_con_1{display:block;} </style> </head> <body> /*********1**********/
<ul id="tab"> <li class="on" id="tab_1" onclick="switchTab(1)">新闻</li> <li id="tab_2" onclick="switchTab(2)">财经</li> <li id="tab_3" onclick="switchTab(3)">娱乐</li> <li id="tab_4" onclick="switchTab(4)">娱乐</li> </ul> <ul id="tab_con"> <li id="tab_con_1">新闻内容</li> <li id="tab_con_2">财经内容</li> <li id="tab_con_3">娱乐内容</li> <li id="tab_con_4">娱乐内容3</li> </ul>
<script type="text/javascript"> function switchTab(n){ for(var i = 1; i <= 4; i ){ document.getElementById("tab_" i).className = ""; document.getElementById("tab_con_" i).style.display = "none"; } document.getElementById("tab_" n).className = "on"; document.getElementById("tab_con_" n).style.display = "block"; } </script> </body> </html></textarea>
提示:您可以先修改部分代码再运行

您可能感兴趣的文章:
js Tab选项卡特效代码
Javascript中常用选项卡3种写法
纯 CSS 选项卡的实现例子
jQuery学习笔记(3)--用jquery(插件)实现多选项卡功能
js自适应滑动门代码
经典的jquery Tab 选项卡通用效果代码
用jQuery打造TabPanel效果代码
Jquery 经典选项卡的实现代码一例
纯CSS实现Tab页切换效果
Jquery tab选项卡的实现代码

上一篇:滑动菜单 下一篇:类qq下拉菜单 代码
[关闭]
~ ~