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

首頁(yè) > 語(yǔ)言 > JavaScript > 正文

JQuery Tab選項(xiàng)卡效果代碼改進(jìn)版

2024-05-06 14:10:41
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
介紹的是基于JQuery實(shí)現(xiàn)的一個(gè)選項(xiàng)卡效果,重點(diǎn)體現(xiàn)在HTML里沒(méi)有內(nèi)聯(lián)事件處理程序,而是定義在js文件里,做到行為與結(jié)構(gòu)的分離。在實(shí)際應(yīng)用過(guò)程中,只 要保證選項(xiàng)卡模塊結(jié)構(gòu)代碼的完整性,就可以任意添加N個(gè)同類選項(xiàng)卡,不需要手動(dòng)在HTML里綁定事件處理程序以及給要隱藏顯示的內(nèi)容層添加ID。
在這里,我又做了部分的修改,增加了選項(xiàng)卡可自動(dòng)切換功能,以及選項(xiàng)卡點(diǎn)擊相應(yīng)還是鼠標(biāo)放上后相應(yīng)的參數(shù),同時(shí)依然支持多次調(diào)用。
現(xiàn)在,我把代碼貼上,與眾博友共享
這是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
*/
//注意:如果調(diào)試出錯(cuò),請(qǐng)檢查您引用的jquery版本號(hào),當(dāng)前引用版本為1.3
//參數(shù)說(shuō)明:
//tabList:包裹選項(xiàng)卡的父級(jí)層
//tabTxt :包裹內(nèi)容層的父級(jí)層
//options.currentTab:激活選項(xiàng)卡的序列號(hào)
//options.defaultClass:當(dāng)前選項(xiàng)卡激活狀態(tài)樣式名,默認(rèn)名字為“current”
//isAutoPlay:是否自動(dòng)切換
//stepTime:切換間隔時(shí)間
//switchingMode:切換方式('c'表示click切換;'o'表示mouseover切換)
//調(diào)用方式 如本頁(yè)最下方代碼
$.fn.tabs = function(tabList, tabTxt, options) {
var _tabList = $(this).find(tabList);
var _tabTxt = $(this).find(tabTxt);
//為了簡(jiǎn)化操作,強(qiáng)制規(guī)定選項(xiàng)卡必須用li標(biāo)簽實(shí)現(xiàn)
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);
//強(qiáng)制規(guī)定內(nèi)容層必須以div來(lái)實(shí)現(xiàn)
_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" });
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 新兴县| 夏津县| 铅山县| 乌拉特后旗| 江孜县| 乐清市| 临夏市| 贵溪市| 安多县| 襄汾县| 乐业县| 卓资县| 阿合奇县| 旬阳县| 额尔古纳市| 陆河县| 和田县| 朝阳区| 丰宁| 肇州县| 库车县| 光泽县| 德格县| 萝北县| 渝中区| 武城县| 北海市| 合阳县| 怀仁县| 江油市| 荆州市| 威海市| 海宁市| 手游| 阳曲县| 宜宾县| 永川市| 威远县| 南乐县| 图片| 阿坝|