jquery实现简单的Tab切换菜单
jquery实现简单的Tab切换菜单
主要代码:
js代码
JavaScript Code
- <script type="text/javascript">
- $(document).ready(function() {
- //Default Action
- $(".tab_content").hide(); //Hide all content
- $("ul.tabs li:first").addClass("active").show(); //Activate first tab
- $(".tab_content:first").show(); //Show first tab content
- //On Click Event
- $("ul.tabs li").click(function() {
- $("ul.tabs li").removeClass("active"); //Remove any "active" class
- $(this).addClass("active"); //Add "active" class to selected tab
- $(".tab_content").hide(); //Hide all tab content
- var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
- $(activeTab).fadeIn(); //Fade in the active content
- return false;
- });
- });
- </script>
主要代码
XML/HTML Code
- <div class="container">
- <ul class="tabs">
- <li class="active"><a href="#tab1">导航菜单</a></li>
- <li><a href="#tab4">TAB标签</a></li>
- </ul>
- <div class="tab_container">
- <div id="tab1" class="tab_content" style="display: block; ">
- <h3><a href="http://www.freejs.net/article_daohangcaidan_13.html">jquery css多级下拉菜单</a></h3>
- <p id="">多级菜单,理论上支持无限多的层级,文件结构非常简单的,具体的请看下面的内容</p>
- </div>
- <div id="tab4" class="tab_content" style="display: none; ">
- <h2>各种tab标签选项卡</h2>
- <h3><a href="http://www.freejs.net/article_tabbiaoqian_17.html">tab标签页面,ajax载入</a></h3>
- <p> tab标签,jquery ajax载入数据库的内容</p>
- </div>
- </div>
- </div>
相关推荐
周公周金桥 2020-09-06
大象从不倒下 2020-07-31
AlisaClass 2020-07-19
MaureenChen 2020-04-21
xingguanghai 2020-03-13
teresalxm 2020-02-18
木四小哥 2013-05-14
SoShellon 2013-06-01
Simagle 2013-05-31
羽化大刀Chrome 2013-05-31
waterv 2020-01-08
LutosX 2013-07-29
vanturman 2013-06-27
wutongyuq 2013-04-12
luoqu 2013-04-10
today0 2020-09-22
89520292 2020-09-18
bigname 2020-08-25