This feature is relatively simple, consolidating the jquery plugin notation, note the introduction of the Jquery.js, custom plug-in path code is as follows:
Page:
<!doctype html>Custom plugins:The plugin follows a fixed template:
Such as
;(function ($) {
/** entry Function **/
$.fn.optionchange = function (opts) {
};
/** plug-in internal logic function **/
$.fn.optionchange.methods = {
};
/** Default parameter Block **/
$.fn.optionchange.defaults = {
};
/** Property Parameter **/
$.fn.optionchange.parseoptions = function (target) {
};
}) (JQuery);
The;(function ($) {/** entry functions **/$.fn.optionchange = function (opts) {This.each (function () {Opts.currobj = $ (this); opts = $. Extend ({},$.fn.optionchange.defaults,opts,$.fn.optionchange.parseoptions); var tobjlen = Opts.currObj.find ('. ') +opts.triggerobjclass). Length;var Lobjlen = Opts.currObj.find ('. ') +opts.linkobjclass). Length;if (Tobjlen && lobjlen && Tobjlen = = Lobjlen) {$. Fn.optionChange.methods.init (opts);});};/ * * Plugin internal logic function **/$.fn.optionchange.methods = {init:function (opts) {var event = Opts.event;var Triggerobjclass = Opts.triggerobjclass;var Linkobjclass = Opts.linkobjclass;var Currobj = Opts.currobj;var LinkSelectFn = Opts.linkselectfn;currobj.find ('. ') +triggerobjclass). On (Event,function () {$this = $ (this), $this. addclass (OPTS.TRIGGERSELECTCSS). Siblings (). Removeclass (OPTS.TRIGGERSELECTCSS); var _linkobj = Currobj.find ('. ') +opts.linkobjclass). EQ ($this. Index ()), _linkobj.addclass (OPTS.LINKSELECTCSS). Siblings (). Removeclass ( OPTS.LINKSELECTCSS);}};/ * * Default parameter Block **/$.fn.optionchange.defaults ={event: ', Triggerobjclass: ' Tiggerclass ', triggerselectcss: ', Linkobjclass: ' Linkclass ', linkselectcss: ', CURROBJ: {}};/** Property parameter This function returns an empty object **/$.fn.optionchange.parseoptions = function (target) {return {};};}) (JQuery);
If you need to know what the attribute parameter means, read: http://blog.csdn.net/pleasurehappy/article/details/46399855
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JS Custom Plugins-Tabs