博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jquery插件开发样例-jquery插件开发(1)
阅读量:7225 次
发布时间:2019-06-29

本文共 2235 字,大约阅读时间需要 7 分钟。

/*! * jQuery lightweight plugin boilerplate * Original author: @ajpiano * Further changes, comments: @addyosmani * Licensed under the MIT license */// the semi-colon before the function invocation is a safety// net against concatenated scripts and/or other plugins// that are not closed properly.;(function ( $, window, document, undefined ) {    // undefined is used here as the undefined global    // variable in ECMAScript 3 and is mutable (i.e. it can    // be changed by someone else). undefined isn't really    // being passed in so we can ensure that its value is    // truly undefined. In ES5, undefined can no longer be    // modified.    // window and document are passed through as local    // variables rather than as globals, because this (slightly)    // quickens the resolution process and can be more    // efficiently minified (especially when both are    // regularly referenced in your plugin).    // Create the defaults once    var pluginName = 'defaultPluginName',        defaults = {            propertyName: "value"        };    // The actual plugin constructor    function Plugin( element, options ) {        this.element = element;        // jQuery has an extend method that merges the        // contents of two or more objects, storing the        // result in the first object. The first object        // is generally empty because we don't want to alter        // the default options for future instances of the plugin        this.options = $.extend( {}, defaults, options) ;        this._defaults = defaults;        this._name = pluginName;        this.init();    }    Plugin.prototype.init = function () {        // Place initialization logic here        // You already have access to the DOM element and        // the options via the instance, e.g. this.element        // and this.options    };    // A really lightweight plugin wrapper around the constructor,    // preventing against multiple instantiations    $.fn[pluginName] = function ( options ) {        return this.each(function () {            if (!$.data(this, 'plugin_' + pluginName)) {                $.data(this, 'plugin_' + pluginName,                new Plugin( this, options ));            }        });    }})( jQuery, window, document );

转载地址:http://pieym.baihongyu.com/

你可能感兴趣的文章
至强E3-1200 系列部分参数
查看>>
PowerShell【变量篇】
查看>>
线段树(单点更新) HDOJ 2795 Billboard
查看>>
十天冲刺---Day4
查看>>
shiro用authc配置后登录成功后不能跳转到index页面
查看>>
25.管道流
查看>>
58.express安装问题:express不是内部也或者外部的命令解决方案
查看>>
MySQL数据库出现The server quit without updating PID file.
查看>>
C++ 前期准备
查看>>
Mysql 技巧
查看>>
得到Revit子窗体
查看>>
聚类算法之K-Means
查看>>
win2008 服务器文件夹权限配置
查看>>
vscode 问题
查看>>
VirtualBox与Genymotion命令行启动
查看>>
selenium常用操作
查看>>
面向对象_描述符
查看>>
http://www.sqlservercentral.com/Forums/Topic611107-146-1.aspx
查看>>
一步一步重写 CodeIgniter 框架 (7) —— Controller执行时将 Model获得的数据传入View中,实现MVC...
查看>>
虚短”“虚断”两板斧,搞定运算放大器 11张大图详(转)感觉特别有用 转过来收藏...
查看>>