Copy codeThe 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 // style selector for sub-options
};
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 );
The call method is simpler:
Copy codeThe Code is as follows:
JQuery (document ). ready (function () {$ (". mytab li "). jqpressTab ({_ tabClass: "style name", _ childs: "child element style name "});});
If you need to customize the selector based on the ID