复制代码 代码如下: /* * jqpressToos1.0 * * Copyright (c) 2011 yepeng * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * */ $.fn.extend({ //插件名称:Tab选项卡 jqpressTab: function(options) { //参数和默认值 var defaults = { _tabClass: null,//选项卡样式 _childs:null //子选项 样式选择器 }; var options = $.extend(defaults, options); var o = options; var parentCate = $(this); var childCate = $(o._childs); parentCate.mouseover(function() { parentCate.removeClass(o._tabClass); $(this).addClass(o._tabClass); for (i = 0; i < parentCate.length; i++) { if (parentCate[i].className == o._tabClass) { childCate[i].style.display = "block"; } else { childCate[i].style.display = "none"; } } }); } }); })(jQuery); 调用方法更简单: 复制代码 代码如下: jQuery(document).ready(function(){ $(".mytab li a").jqpressTab({ _tabClass: "样式名称", _childs: "子元素样式名称" });}); 如果需要根据ID做选择器自己扩展去吧,呵呵
推荐阅读
从jQuery.camelCase()学习string.replace() 函数学习
功能 camelCase函数的功能就是将形如background-color转化为驼峰表示法:backgroundColor。 此函数在jQuery的data函数,以及涉及到css的诸多函数中都有用到。 jQuery的实现 复制代码 代码如下: //正则匹配 rdashAl>>>详细阅读
本文标题:jquery tab插件精简版分享
地址:http://www.17bianji.com/kaifa2/JS/24195.html
1/2 1