search
HomeWeb Front-endJS TutorialTalk about the understanding of jquery ui tabs_jquery

jquery ui click here to download , you can also go to the official website to view documentation help.

1 attribute

1.11 ajaxOptions, add an ajax option when the tab loads content. The added ajax option only works when using ajax. The default value is null. In the above example, two options, beforeSend and success, are added. There are some other options for ajax, please refer to jquery ajax, which will not be explained in detail here. . .

1.12 Initialization setting example: Please note that $('.selector') is the class name of tabs. In this example, .selector=#tabs will not be explained again.

$('.selector').tabs({ ajaxOptions: { async: false } }); //Here, asynchronous is changed to synchronous.

1.13 Parameter acquisition and setting after initialization: Please note: getter means acquisition, pronounced as: Getter, setter means setting, pronounced as: Setter, which will not be explained in the future.

//getter
var ajaxOptions = $('.selector').tabs('option', 'ajaxOptions');
//setter
$('.selector').tabs('option', 'ajaxOptions', { async: false });

1.21 cache defaults to false, no cache. This option is used for ajax calls. Simply put, no cache means it will be refreshed every time a request is sent; with cache, it will be refreshed on the first request and will not be refreshed in the future. Closing the page is another matter.

ajaxOptions:{cache:false} should have the same function as this.

1.22 Initialization setting example:

Copy code The code is as follows:

$('.selector').tabs({ cache: true });

2.23 Parameter acquisition and setting after initialization:

//getter
var cache = $('.selector').tabs('option', 'cache');
//setter
$('.selector').tabs('option', 'cache', true);

1.31collapsible, which means foldable. The default option is false and cannot be folded. If set to true, allows the user to collapse the contents of the selected tab. Let’s put it this way: Click Tab 2 once, and the content of Tab 2 is displayed. At this time, click Tab 2 again, and the content area of ​​the tab is collapsed. Click Tab 2 again, and the content area of ​​the tab is expanded again. . Do you understand? I know you don’t understand. If you don’t understand, just try the example above.

1.32 Initialization setting example:

Copy code The code is as follows:

$('.selector').tabs({ collapsible: true });

1.33 Parameter acquisition and setting after initialization: please refer to 1.23...

1.41 cookie default value is null, cookie plug-in is required. Save the last selected tab to a cookie. Examples of available options: (example): { expires: 7, path: '/', domain: 'jquery.com', secure: true }.

1.42 Initialization setting example: $('.selector').tabs({ cookie: { expires: 30 } });

1.43 Parameter acquisition and setting after initialization: please refer to 1.23...

1.51deselectable defaults to false and seems to have the same effect as collapsible.

1.61 disabled sets which tabs are unavailable. It is an array example [0,1,2], which is the first, second, and third tabs. The default is [].

1.62 Initialization setting example: $('.selector').tabs({ disabled: [1, 2] });

1.63 Parameter acquisition and setting after initialization: please refer to 1.23...

1.71 event, the event for switching tabs, the default is 'click', click to switch tabs.

1.72 Initialization setting example: $('.selector').tabs({ event: 'mouseover' }); //Switch tabs by sliding the mouse over

1.73 Parameter acquisition and setting after initialization: please refer to 1.23...

1.81 fx, animation effect when switching tabs, default: null, no animation effect,

1.82 Initialization settings: Please see the top example.

1.83 Parameter acquisition and setting after initialization: please refer to 1.23...

1.91 idPrefix, when using ajax, the idPrefix option can add a unique id to it, the default is: 'ui-tabs-'.

1.92 Initialization setting example: $('.selector').tabs({ idPrefix: 'ui-tabs-primary' });

1.93 Parameter acquisition and setting after initialization: please refer to 1.23...

1.101 selected, during initialization, which tab is selected, the default is 0, which means the first tab is selected.

1.102 Initialization setting example: $('.selector').tabs({ selected: 3 });

1.103 Parameter acquisition and setting after initialization: please refer to 1.23...

1.111 spinner, when the remote content is loaded, (ajax), the html content of the spinner string will be displayed on the title of the tab. (I’m very surprised, I tried it myself, why doesn’t it work?)

1.112 Initialization setting example: $('.selector').tabs({ spinner: 'Retrieving data...' });

1.113 Parameter acquisition and setting after initialization: please refer to 1.23...

1.121 panelTemplate ,

1.131 tabTemplate ,

2 Events

First give an example of event binding, please note:

$('#example').bind('tabsselect', function(event, ui) {
  ui.tab   // 被选中(点击后)的选项卡元素
  ui.panel  //这个元素包含被选中(点击后)的选项卡的内容
  ui.index  //返回一个被选中(或点击后)选项卡的索引值(从0开始)
});

2.11 select 类型:tabsselect ,点击选项卡时触发该事件。

2.12 初始化时绑定事件:

$('.selector').tabs({
  select: function(event, ui) { ... }
});

2.13 在初始化后使用事件绑定绑定该事件:

$('.selector').bind('tabsselect', function(event, ui) {
...
});

2.21 load,类型:tabsload 一个远程(ajax)选项卡的内容被加载完成后触发该事件。

2.22 参考2.12

2.23 参考2.13

2.31 show,类型:tabsshow 当选项卡显示后触发该事件。

2.41 add,类型:tabsadd ,当一个选项卡被添加后触发。

2.51 remove ,类型tabsremove ,当一个选项卡被删除后触发。

2.61 enable ,类型tabsenable ,当一个选项卡可用时触发。

2.71 disable,类型tabsdisable,当一个选项卡不可用时触发。

3 方法

3.11 destroy,哈哈,又到了我最喜欢的摧毁地球时间。例:.tabs( 'destroy' )

3.21 disable,整个选项卡不可用。

3.31 enable,整个选项卡可用。.tabs( 'enable' )

3.41 option,设置属性。例:.tabs( 'option' , optionName , [value] )

3.51 add,remove,添加、删除选项卡。例:.tabs( 'add' , url , label , [index] ) ,.tabs( 'remove' , index )

3.61 enable,设置某个选项卡标签可用。例:.tabs( 'enable' , index )

3.71 disable,设置某个选项卡标签不可用。例:.tabs( 'disable' , index )

3.81 select,选择一个选项卡标签。例:.tabs( 'select' , index ) ,index从0开始。

3.91 load,重载一个ajax选项卡的内容,这个一直载入远程内容,即使cache设置为true,第二个参数是要重载选项卡的索引值。

例:.tabs( 'load' , index )

3.101 url,当一个ajax选项卡将要加载时,改变url。.tabs( 'url' , index , url )

3.111 abort,中止所有运行在tab标签上的ajax请求或动画。.tabs( 'abort' )

3.121 rotate, 自动翻滚选项卡标签。.tabs('rotate',ms,[countinue]),第二个参数是毫秒,是两个标签自动翻滚所需要的时间,设为0或null为停止翻滚。第三个参数是设置当用户选择一个

选项卡标签后是否继续翻滚,默认为:false,不继续。

真累,歇歇再说吧。。。

4 技巧

4.1 如何接收已选中选项卡标签的索引值?

例:

var $tabs = $('#example').tabs();
var selected = $tabs.tabs('option', 'selected'); // => 0

4.2 如何用一个其它元素代替选项卡单击事件来切换选项卡?

例:

var $tabs = $('#example').tabs(); // 第一个标签被选中
$('#my-text-link').click(function() { // 绑定单击事件
  $tabs.tabs('select', 2); // 切换到第三个选项卡标签
  return false;
});

4.3 如何立刻选择刚添加的选项卡标签?

例:

var $tabs = $('#example').tabs({
  add: function(event, ui) {
    $tabs.tabs('select', '#' + ui.panel.id);
  }
});

4.4 如何在一个新窗口中打开选项卡标签?

例:$('#example').tabs({

  select: function(event, ui) {
    location.href = $.data(ui.tab, 'load.tabs');
    return false;
  }
});
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
JavaScript: Exploring the Versatility of a Web LanguageJavaScript: Exploring the Versatility of a Web LanguageApr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The Evolution of JavaScript: Current Trends and Future ProspectsThe Evolution of JavaScript: Current Trends and Future ProspectsApr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

Demystifying JavaScript: What It Does and Why It MattersDemystifying JavaScript: What It Does and Why It MattersApr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

Is Python or JavaScript better?Is Python or JavaScript better?Apr 06, 2025 am 12:14 AM

Python is more suitable for data science and machine learning, while JavaScript is more suitable for front-end and full-stack development. 1. Python is known for its concise syntax and rich library ecosystem, and is suitable for data analysis and web development. 2. JavaScript is the core of front-end development. Node.js supports server-side programming and is suitable for full-stack development.

How do I install JavaScript?How do I install JavaScript?Apr 05, 2025 am 12:16 AM

JavaScript does not require installation because it is already built into modern browsers. You just need a text editor and a browser to get started. 1) In the browser environment, run it by embedding the HTML file through tags. 2) In the Node.js environment, after downloading and installing Node.js, run the JavaScript file through the command line.

How to send notifications before a task starts in Quartz?How to send notifications before a task starts in Quartz?Apr 04, 2025 pm 09:24 PM

How to send task notifications in Quartz In advance When using the Quartz timer to schedule a task, the execution time of the task is set by the cron expression. Now...

In JavaScript, how to get parameters of a function on a prototype chain in a constructor?In JavaScript, how to get parameters of a function on a prototype chain in a constructor?Apr 04, 2025 pm 09:21 PM

How to obtain the parameters of functions on prototype chains in JavaScript In JavaScript programming, understanding and manipulating function parameters on prototype chains is a common and important task...

What is the reason for the failure of Vue.js dynamic style displacement in the WeChat mini program webview?What is the reason for the failure of Vue.js dynamic style displacement in the WeChat mini program webview?Apr 04, 2025 pm 09:18 PM

Analysis of the reason why the dynamic style displacement failure of using Vue.js in the WeChat applet web-view is using Vue.js...

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use