Home > Web Front-end > JS Tutorial > body text

jquery tools tabs tab/tab_jquery

WBOY
Release: 2016-05-16 18:49:12
Original
1332 people have browsed it

Although it is convenient and easy to use, I personally feel that its performance in UI is not very good. Today I accidentally saw jquery tools - a UI performance framework based on jquery. Its UI function display style is similar to (or imitates) flex. The framework provides six major categories of functions: tabs (tabs/tabs) overlay (overlay), tooltip (prompt box), scrollable (scrolling information bar), expose (highlighting), flahembed (video playback embedment) (its official The website calls itself six major tools), and each of these six major categories of functions has its own independent support package, which does not interfere with each other. Users can download according to their own needs, thus reducing the impact of js file downloads on page loading speed. influence. Although the functions are not very comprehensive, they can be said to be few but refined - they are all commonly used functions at present, and they can well make up for some shortcomings of jquery ui, and strengthen the UI functions of jquery to a certain extent. In fact, what I appreciate most are those flex-like styles, which can greatly enhance the user experience while effectively controlling development costs.
Today I took a closer look at the tabs of jquery tools. Let’s make a summary based on its official documentation.
First give the target html code of the operation:

Copy the code The code is as follows:






Here you can see tabs in action. They are the most popular user-interface component on the web. And for good reason: they are intuitive to use, people are used to them, and above all your can organize your pages more friendly.


tabl contentopen table2



Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed lorem. Aenean commodo pede a eros volutpat viverra. Pellentesque a nisl. /a>




Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.


tab3 content

>This function is implemented through the jqueryObject.tabs() method, where the tabs method provides the following three methods:
1. $("ul.tabs-t").tabs("div.tabsContent>div") //This method can simply organize tabs
2. $("ul.tabs-t").tabs("div.tabsContent>div" ,{config object}) //This method uses the configuration object to Tabs are organized and suitable for various tab display.
3. $("ul.tabs-t").tabs("div.tabsContent>div" ,callback function) //Perform further operations on tabs through the callback function.
The following is an explanation of the implementation and description of the config object parameters in 2:




Copy the code

The code is as follows:

current:'current',//为当前tab的增加的class名称,默认为current
effect:"fade",//每个tab的panel内容显示方式为从整体逐渐显示
//effect:"slide",//点击tab的panel出现在当前tab的panel下面,并覆盖掉当前panel
//effect:"horizontal",//当前tab的panel逐渐从右向左收缩并最终消失,点击panel的内容占据相应位置,比较适合水平导航
fadeInSpeed:1000,//设置panel显示的速度,设置该属性在effect置为fade时有效,默认值为200毫秒
event:"mouseover",//指定触发tab切换的事件,默认是单击鼠标,可选择的触发事件有“mouseover”,"dbclick"
history:true,//类似javascript的history功能,默认为false,当用户点击浏览器的前进后后退按钮后,如果此处设置为true,那么就会回退到上次点击的tab,而不是跳转到其他页面去
initialIndex:1,//设置默认显示的tab
tabs:"a",//设置tab对应的标签元素,默认为"a",这里也可以设为"li",该处相当于jquery的选择器
api:false,//设置当前tab所在容器的返回类型类型。如果为false(默认值),以jquery对象返回;否则,以js对象返回。如果存在多个值,返回最后一个值。
onBeforeClick:function( index){
//alert(this.getCurrentTab().text());//返回当前tab的名称
return true;
},//在tab被点击之前调用的函数,如果该函数返回false,那么该tab不会被触发;返回的是一个tab对象,对于该对象的操作,参见tab相关方法;改返回函数有一个参数,为当前tab的索引
onClick:function(index){
return true;
}//在tab被点击的时候调用的函数,其他用法同onBeforeClick

更直观的说明如下:
属性名称 默认值 描述
current
'current'
为当前tab的增加的class名称
effect
default'
fade':每个tab的panel内容显示方式为从整体逐渐显示;面,并覆盖掉当前panel
'slide':点击tab的panel出现在当前tab的panel下
horizontal':当前tab的panel逐渐从右向左收缩并最终消失,点击panel的内容占据相应位置,比较适合水平导航
fadeInSpeed
200
设置panel显示的速度,设置该属性在effect置为fade时有效,默认值为200毫秒
event
'click'
指定触发tab切换的事件,默认是单击鼠标,可选择的触发事件有“mouseover”,"dbclick"
history FALSE 类似javascript的history功能当用户点击浏览器的前进后后退按钮后,如果此处设置为true,那么就会回退到上次点击的tab,而不是跳转到其他页面去
initialIndex
0
设置默认显示的tab
tabs
a'
设置tab对应的标签元素,默认为"a",这里也可以设为"li",该处相当于jquery的选择器
api
FALSE
设置当前tab所在容器的返回类型类型。如果为false(默认值),以jquery对象返回;否则,以js对象返回。如果存在多个值,返回最后一个值。
onBeforeClick
null
在tab被点击之前调用的函数,如果该函数返回false,那么该tab不会被触发;返回的是一个tab对象,对于该对象的操作,参见tab相关方法;改返回函数有一个参数,为当前tab的索引
onClick
null
在tab被点击的时候调用的函数,其他用法同onBeforeClick
此外,tabs也提供了获取tabs的一系列方法,具体实现及说明如下:
复制代码 代码如下:

var api=$("ul.tabs-t").tabs();//先通过获取tab容器获取tab
//api.next();//跳转到下一个tab
//api.click();
//alert(api.getConf().tabs);//返回api的配置对象,这里获取配置对象的tabs属性的值
api.getCurrentPane();//获取当前的panel
api.getCurrentTab();//获取当前tab
api.getIndex();//获取当前tab的index
//alert(api.getPanes());//获取所有的panel
//alert(api.getTabs());//获取所有的tab
api.prev();//跳转到上一个tab
api.onBeforeClick=function(){
return true;
}//同配置对象的BeforeClick,一个对象可以绑定多个Beforeclick事件
api.onClick=function(){
return true;
}//同配置对象的Click,一个对象可以绑定多个Beforeclick事件

 更直观的说明如下:

方法 返回值 描述
getConf()
API
返回api的配置对象
getCurrentPane()
jQuery
获取当前的panel
getCurrentTab()
jQuery
获取当前tab
getIndex()
integer
获取当前tab的index
getTabs()
jQuery
获取所有的tab
getPanes()
jQuery
获取所有的panel
next()
API
跳转到下一个tab
prev()
API
Jump to the previous tab
onBeforeClick()
API
Same as BeforeClick of the configuration object, one object can be bound to multiple Beforeclick events
onClick()
API
//Same as the Click configuration object, one object can be bound to multiple Beforeclick events

Finally, take a few screenshots of its official website as the end of this article.

1.Normal tabs

jquery tools tabs (tabs/tabs) - gaoyusi - My co<wbr>de life

2. Horizontally expanded tabs

jquery tools tabs (tabs/tabs) - gaoyusi - My co<wbr>de life

3. Class prompt box

jquery tools tabs (tabs/tabs) - gaoyusi - My co<wbr>de life

4.Guide

jquery tools tabs (tabs/tabs) - gaoyusi - My co<wbr>de life

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template