tab标签可以显示指定项目,清除tab效果并重建
XML/HTML Code
- <div class="wrap">
- <h2>Basic tabs example</h2>
- <div class="set set-1">
- <div class="panel panel-1">
- <h2>Panel 1</h2>
- <p><a href="http://freejs.net/article_fenye_19.html">jquery 无刷新翻页</a>
- 本例与《jquery 翻页分页》的区别在于本例更实用,翻页数字太多的时候会隐藏中间的部分。数据库与《jquery 翻页分页》的数据库相同</p>
- <button class="btn">Show tab 3</button>
- <button class="destroy">Destroy</button>
- <button class="apply">Apply</button>
- </div>
- <div class="panel panel-2">
- <h2>Panel 2</h2>
- <p>2</p>
- </div>
- <div class="panel panel-3">
- <h2>Panel 3</h2>
- <p>3</p>
- </div>
- <div class="panel panel-4">
- <h2>Panel 4</h2>
- <p>4</p>
- </div>
- </div>
- <h2>With callback on tab select</h2>
- <div class="set set-2">
- <div class="panel panel-1">
- <header class="heading">Panel 1</header>
- <p>1</p>
- <button class="btn">Show tab 2</button>
- </div>
- <div class="panel panel-2">
- <header class="head">Panel 2</header>
- <p>2</p>
- </div>
- <div class="panel panel-3">
- <header class="h1">Panel 3</header>
- <p>3</p>
- </div>
- </div>
- </div>
JavaScript Code
- <script>
- $(function() {
- $(".set-1").mtabs();
- $(".set-2").mtabs({
- tab_text_el: ".heading, .head, header",
- onTabSelect: function(idx) {
- console.log("Selected tab is: " + idx);
- },
- onReady: function () {
- console.log('Set 2 ready!');
- }
- });
- $('.set-1 .panel-1 .btn').on('click', function(event) {
- $('.set-1').mtabs('show', 2);
- event.preventDefault();
- });
- $('.set-1 .panel-1 .destroy').on('click', function(event) {
- $('.set-1').mtabs('destroy');
- event.preventDefault();
- });
- $('.set-1 .panel-1 .apply').on('click', function(event) {
- $('.set-1').mtabs();
- event.preventDefault();
- });
- $('.set-2 .panel-1 .btn').on('click', function(event) {
- $('.set-2').mtabs('show', 1);
- event.preventDefault();
- });
- });
- </script>
原文地址:http://www.freejs.net/article_tabbiaoqian_230.html