`

关于Jquery的plugin使用

阅读更多

// jQuery, the fn property is just an alias to the prototype property.

//The jQuery identifier (or $) is just a constructor function, and all instances created with it, inherit from the constructor's prototype.

//A simple constructor function:

function Test() {
  this.a = 'a';
}
Test.prototype.b = 'b';

var test = new Test(); 
test.a; // "a", own property
test.b; // "b", inherited property
A simple structure that resembles the architecture of jQuery:

(function() {
  var foo = function(arg) { // core constructor
    // ensure to use the `new` operator
    if (!(this instanceof foo))
      return new foo(arg);
    // store an argument for this example
    this.myArg = arg;
    //..
  };

  // create `fn` alias to `prototype` property
  foo.fn = foo.prototype = {
    init: function () {/*...*/}
    //...
  };

  // expose the library
  window.foo = foo;
})();

// Extension:

foo.fn.myPlugin = function () {
  alert(this.myArg);
  return this; // return `this` for chainability
};

foo("bar").myPlugin(); // alerts "bar"

分享到:
评论

相关推荐

    jQuery全能权威指南:jQuery Core+jQuery Plugin+jQuery UI+jQuery Mobile 源码

    、CSS和JavaScript知识的开发者,内容覆盖了jQuery知识体系的全部内容,包括jQuery Core、jQuery Plugin 、jQuery UI、jQuery Mobile以及大量第三方的插件库和2800多个应用jQuery技术的网页参考。

    jquery 英文教程 jQuery Plugin Development Beginner’s Guide PDF

    jquery 的经典 英文书 jQuery Plugin Development Beginner’s Guide.PDF

    jQuery plugin for autocomplete - jQuery自动完成插件

    jQuery plugin for autocomplete - jQuery自动完成插件

    jQuery Media Plugin Demo

    要使用jQuery Media Plugin,首先需要在页面中引入jQuery库和jQuery Media Plugin的脚本文件。然后选择要添加多媒体功能的元素,调用`.media()`方法,并传入配置对象,例如: ```html <script src="jquery.js"> ...

    表格拖拽排序插件 Table Drag and Drop JQuery plugin v0.7

    表格拖拽排序插件 Table Drag and Drop JQuery plugin v0.7 最新0.7版本

    simple jQuery date-picker plugin 使用

    通过以上步骤,你就可以在项目中成功集成并使用“simple jQuery date-picker plugin”。虽然这个插件的功能相对基础,但它足够应对大部分简单的日期选择场景。如果需要更复杂的功能,如多语言支持、日期范围选择等,...

    struts2-jquery-plugin使用手册,自己写的

    - Struts2-jQuery-Plugin支持自定义JavaScript事件处理,可以使用`onComplete`、`beforeSubmit`等属性绑定回调函数,实现更复杂的业务逻辑。 - 使用`event`属性,可以触发特定的jQuery事件,如`open`、`close`等。...

    struts2-jquery-plugin-3.1.0.jar

    struts2-jquery-plugin-3.1.0.jar

    JQuery validation plugin学习资料

    在使用jQuery Validation Plugin前,首先需要确保你的项目中已经包含了jQuery库。你可以通过CDN链接或者本地引入的方式获取jQuery。接着,你需要下载或通过npm、yarn等包管理器安装jQuery Validation Plugin。安装...

    aptana 2.0 jquery plugin

    aptana jquery plugin js javascript

    jQuery Orbit Plugin 1.2.3

    总之,jQuery Orbit Plugin 1.2.3 是一个强大且易于使用的轮播解决方案,能够帮助开发者快速构建高质量的网页轮播效果,提高网站的用户体验。无论你是新手还是经验丰富的开发者,这个插件都能满足你对轮播组件的各种...

    JQuery Cycle Plugin

    **jQuery Cycle Plugin** 是一个广泛使用的JavaScript库,专门用于创建动态和交互式的图像滑块、轮播和幻灯片效果。这个插件充分利用了jQuery的简洁API和强大的DOM操作功能,使得开发者能够轻松地在网站上实现各种...

    [jQuery plugin]slider demo

    * usage as: * var slider = $.fn.jSlider({...}); * slider.setSliderValue(value,callback);

    使用jQuery开发Plugin插件指南

    使用jQuery开发Plugin插件指南

    jQuery摄像头插件jquery-webcam-plugin

    要使用`jQuery webcam plugin`,首先需要在项目中引入jQuery库以及插件的JavaScript和CSS文件。接着,需要在HTML中创建一个用于显示摄像头预览的元素,例如一个`div`,并为其添加特定的ID。然后,通过以下JavaScript...

    tableExport.jquery.plugin-1.10.22.zip

    总的来说,"tableExport.jquery.plugin-1.10.22.zip"是前端开发中一个便捷的工具,它通过jQuery实现了表格数据的快速导出,提升了用户体验,简化了开发者的工作。无论是在企业级应用还是个人项目中,都能看到其广泛...

    struts2-jquery-plugin-2.0.0

    struts2-jquery-plugin-2.0.0 struts2-jquery-plugin-2.0.0 struts2-jquery-plugin-2.0.0

    关于jquery validate plugin 指定需要验证对象解决方案

    《关于jQuery Validate Plugin指定需要验证对象的解决方案》 在Web开发中,表单验证是必不可少的一环,确保用户输入的数据符合预设的规则。jQuery Validate Plugin是一款强大的客户端表单验证插件,它使得这一过程...

    Ellipsis – Jquery Ellipsis Plugin

    **jQuery Ellipsis 插件详解** 在Web开发中,我们经常遇到一个问题:如何优雅地处理过长的文字内容,尤其是在有限的显示空间内。这正是jQuery Ellipsis插件所解决的问题。该插件提供了一个简洁而实用的方法,可以...

    struts2-jquery-plugin

    struts2 jquery plugin ,学习struts2 ,又希望在其中使用Jquery的朋友,不妨看看

Global site tag (gtag.js) - Google Analytics