简单 用户友好 选项卡插件 jquery Tabs.js

  • 源码大小:9.12KB
  • 所需积分:1积分
  • 源码编号:19JP-3576
  • 浏览次数:565次
  • 最后更新:2023年06月28日
  • 所属栏目:其他
本站默认解压密码:19jp.com 或 19jp_com

简介

一个轻量级、语义化(SEO友好)且易于配置的jQuery选项卡插件,它提供了在页面上显示多个内容块的干净简单的功能

它可以开箱即用地使用HTML元素,您可以使用任何您喜欢的HTML元素和结构。

请参阅实际操作:

如何使用它:

1.将jQuery库和选项卡插件的文件插入页面。

  1. <link rel="stylesheet" href="jquery-tabs.css" />
  2. <script src="/path/to/cdn/jquery.min.js"></script>
  3. <script src="jquery-tabs.js"></script>

2.为选项卡UI创建HTML。该插件适用于任何HTML元素,即使它们实际上不是选项卡。

  1. <div class="content">
  2. <section>
  3. <h3>JavaScript</h3>
  4. <p>JavaScript, often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. </p>
  5. <p>Over 97% of websites use JavaScript on the client side for web page behavior, often incorporating third-party libraries. </p>
  6. </section>
  7. <section>
  8. <h3>HTML</h3>
  9. <p>The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. </p>
  10. <p>It can be assisted by technologies such as Cascading Style Sheets and scripting languages such as JavaScript.</p>
  11. </section>
  12. <section>
  13. <h3>CSS/CSS3</h3>
  14. <p>Cascading Style Sheets is a style sheet language used for describing the presentation of a document written in a markup language such as HTML. </p>
  15. <p>CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript. </p>
  16. </section>
  17. </div>

3.调用顶部容器上的函数并完成。

  1. jQuery('.content').createTabs({
  2.  
  3. // default: section
  4. children: 'section',
  5.  
  6. // default: h2
  7. childrenTitle: 'h3',
  8. });

4.配置fadeIn和fadeOut动画。0=禁用。

  1. jQuery('.content').createTabs({
  2.  
  3. // default: 500
  4. fade: 300
  5. });

5.在选项卡UI的底部添加下一个/上一个导航按钮。

  1. jQuery('.content').createTabs({
  2.  
  3. // button text
  4. prevText: 'Prev',
  5. nextText: 'Next',
  6.  
  7. // additional CSS class
  8. prevClass: 'btn',
  9. nextClass: 'btn',
  10.  
  11. });

6.在选项卡更改时执行一个功能。

  1. jQuery('.content')
  2. .on('tab_change', function(){
  3. alert('TAB CHANGED!');
  4. })

预览截图