Home > Web Front-end > JS Tutorial > jquery tab plug-in simplified version sharing_jquery

jquery tab plug-in simplified version sharing_jquery

WBOY
Release: 2016-05-16 18:02:31
Original
963 people have browsed it
Copy code The code is as follows:

/*
* jqpressToos1.0
*
* Copyright (c) 2011 yepeng
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
*/

$.fn.extend({
//Plug-in name: Tab
jqpressTab: function(options) {
//Parameters and default values
var defaults = {
_tabClass: null,//tab style
_childs:null //child option style selector
};
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);

Calling the method is simpler:
Copy code The code is as follows:

jQuery(document).ready(function(){ $ (".mytab li a").jqpressTab({ _tabClass: "Style name", _childs: "Child element style name" });});

If you need to make your own selector based on ID Go ahead and expand it, haha
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