国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JQuery Tab選項卡效果代碼改進版

2019-11-21 00:37:08
字體:
來源:轉載
供稿:網友
介紹的是基于JQuery實現的一個選項卡效果,重點體現在HTML里沒有內聯事件處理程序,而是定義在js文件里,做到行為與結構的分離。在實際應用過程中,只 要保證選項卡模塊結構代碼的完整性,就可以任意添加N個同類選項卡,不需要手動在HTML里綁定事件處理程序以及給要隱藏顯示的內容層添加ID。
在這里,我又做了部分的修改,增加了選項卡可自動切換功能,以及選項卡點擊相應還是鼠標放上后相應的參數,同時依然支持多次調用。
現在,我把代碼貼上,與眾博友共享
這是js腳本
復制代碼 代碼如下:

/* jquery-fn-accordion v0
* Based on jQuery JavaScript Library v3
* http://jquery.com/
*
* The author of the following code: miqi2214 , wbpbest
* Blog:eycbest.cnblogs.com , miqi2214.cnblogs.com
* Date: 2010-3-10
*/
//注意:如果調試出錯,請檢查您引用的jquery版本號,當前引用版本為1.3
//參數說明:
//tabList:包裹選項卡的父級層
//tabTxt :包裹內容層的父級層
//options.currentTab:激活選項卡的序列號
//options.defaultClass:當前選項卡激活狀態樣式名,默認名字為“current”
//isAutoPlay:是否自動切換
//stepTime:切換間隔時間
//switchingMode:切換方式('c'表示click切換;'o'表示mouseover切換)
//調用方式 如本頁最下方代碼
$.fn.tabs = function(tabList, tabTxt, options) {
var _tabList = $(this).find(tabList);
var _tabTxt = $(this).find(tabTxt);
//為了簡化操作,強制規定選項卡必須用li標簽實現
var tabListLi = _tabList.find("li");
var defaults = { currentTab: 0, defaultClass: "current", isAutoPlay: false, stepTime: 2000, switchingMode: "c" };
var o = $.extend({}, defaults, options);
var _isAutoPlay = o.isAutoPlay;
var _stepTime = o.stepTime;
var _switchingMode = o.switchingMode;
_tabList.find("li:eq(" + o.currentTab + ")").addClass(o.defaultClass);
//強制規定內容層必須以div來實現
_tabTxt.children("div").each(function(i) {
$(this).attr("id", "wp_div" + i);
}).eq(o.currentTab).css({ "display": "block" });
tabListLi.each(
function(i) {
$(tabListLi[i]).mouseover(
function() {
if (_switchingMode == "o") {
$(this).click();
}
_isAutoPlay = false;
}
);
$(tabListLi[i]).mouseout(
function() {
_isAutoPlay = true;
}
)
}
);
_tabTxt.each(
function(i) {
$(_tabTxt[i]).mouseover(
function() {
_isAutoPlay = false;
}
);
$(_tabTxt[i]).mouseout(
function() {
_isAutoPlay = true;
}
)
});
// }
// else {
tabListLi.each(
function(i) {
$(tabListLi[i]).click(
function() {
if ($(this).className != o.defaultClass) {
$(this).addClass(o.defaultClass).siblings().removeClass(o.defaultClass);
}
if ($.browser.msie) {
_tabTxt.children("div").eq(i).siblings().css({ "display": "none" });
_tabTxt.children("div").eq(i).fadeIn(600);
} else {
_tabTxt.children("div").eq(i).css({ "display": "block" }).siblings().css({ "display": "none" }); //標準樣式
}
}
)
}
);
// }
function selectMe(oo) {
if (oo != null && oo.html() != null && _isAutoPlay) {
oo.click();
}
if (oo.html() == null) {
selectMe(_tabList.find("li").eq(0));
} else {
window.setTimeout(selectMe, _stepTime, oo.next());
}
}
if (_isAutoPlay) {
//alert("_isAutoPlay:" + _isAutoPlay);
selectMe(_tabList.find("li").eq(o.currentTab));
}
//alert(_isAutoPlay);
return this;
};
var userName = "wbpbest";
var __sti = setInterval;
window.setInterval = function(callback, timeout, param) {
var args = Array.prototype.slice.call(arguments, 2);
var _cb = function() {
callback.apply(null, args);
}
__sti(_cb, timeout);
}
//window.setInterval(hello,3000,userName);
var __sto = setTimeout;
window.setTimeout = function(callback, timeout, param) {
var args = Array.prototype.slice.call(arguments, 2);
var _cb = function() {
callback.apply(null, args);
}
__sto(_cb, timeout);
}

演示地址:http://demo.VeVB.COm/js/wbpbest/index.html

打包下載地址 //m.survivalescaperooms.com/jiaoben/25569.html
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 株洲市| 禄丰县| 历史| 定州市| 武城县| 吉木萨尔县| 佛坪县| 河东区| 西丰县| 道真| 洛南县| 凌源市| 乐都县| 红桥区| 涞水县| 台东市| 马山县| 南宫市| 唐海县| 栖霞市| 辽源市| 从江县| 弋阳县| 资阳市| 台北县| 恩施市| 高要市| 武城县| 霍州市| 龙江县| 长宁县| 桂平市| 乌兰县| 光泽县| 南部县| 甘洛县| 梅州市| 新巴尔虎左旗| 青河县| 六盘水市| 昭通市|