JS Custom Plugins-Tabs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.