What does jQuery.fn mean?
n 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"
What does jQuery.fn mean?的更多相关文章
- jquery.fn.extend与jquery.extend--(初体验二)
1.jquery.extend(object); 为扩展jQuery类本身.为类添加新的方法. jquery.fn.extend(object);给jQuery对象添加方法. $.extend({ a ...
- jQuery为开发插件提拱了两个方法:jQuery.fn.extend(); jQuery.extend();
jQuery为开发插件提拱了两个方法,分别是: jQuery.fn.extend(); jQuery.extend(); jQuery.fn jQuery.fn = jQuery.prototype ...
- 记jQuery.fn.show的一次踩坑和问题排查
最近很少已经很少用jQuery,因为主攻移动端,常用Zepto,其实很多细节和jQuery并不一样.最近又无意中接触到了PC的需求和IE6, 使用了jQuery,刚好踩坑了,特意记录一下. 本文内容如 ...
- jQuery.extend和jQuery.fn.extend的区别【转】
解释的很有意思,清晰明了又有趣,转来分享下,哈哈哈 jQuery.extend和jQuery.fn.extend的区别,其实从这两个办法本身也就可以看出来.很多地方说的也不详细.这里详细说说之间的区别 ...
- ES6的Iterator,jquery Fn
ES6的Iterator对象详解 Iterator实现原理 创建一个指针对象,指向当前数据结构的起始位置.也就是说,遍历器对象本质上,就是一个指针对象. 第一次调用指针对象的next方法,可以将指针指 ...
- jQuery原生框架中的jQuery.fn.extend和jQuery.extend
extend 方法在 jQuery 中是一个很重要的方法,jQuey 内部用它来扩展静态方法或实例方法,而且我们开发 jQuery 插件开发的时候也会用到它.但是在内部,是存在 jQuery.fn.e ...
- jQuery.fn.extend() 与 jQuery.extend()
jQuery.fn如何扩展. jQuery插件 $.fn(object)与$.extend(object) jQuery提供了两个方法帮助开发插件 $.extend(object);扩展jQuery类 ...
- jQuery.fn.extend(object) object中this的指向
看到下面的代码后,一下子懵逼了.这个this指向哪儿去了. jQuery.fn.extend({ check: function() { return this.each(function() { t ...
- jQuery.extend()方法和jQuery.fn.extend()方法源码分析
这两个方法用的是相同的代码,一个用于给jQuery对象或者普通对象合并属性和方法一个是针对jQuery对象的实例,对于基本用法举几个例子: html代码如下: <!doctype html> ...
- 区别和详解:jQuery extend()和jQuery.fn.extend()
1.认识jQuery extend()和jQuery.fn.extend() jQuery的API手册中,extend方法挂载在jQuery和jQuery.fn两个不同对象上方法,但在jQuery内部 ...
随机推荐
- 用js 转化大小写
function capitalize(string){ var words =string.split(" "); for(var i=0;i<words.length;i ...
- idea cannot download sources解决办法
当我们点击Download Sources时: 有时候idea会出现cannot download sources的情况,如下图 解决办法如下:打开idea右下角的terminal 在里面输入 mvn ...
- 在CentOS6.4上安装GitLab
1.Install and configure the necessary dependencies On CentOS 6 (and RedHat/Oracle/Scientific Linux 6 ...
- [Python3网络爬虫开发实战] 1.2.1-Requests的安装
由于Requests属于第三方库,也就是Python默认不会自带这个库,所以需要我们手动安装.下面我们首先看一下它的安装过程. 1. 相关链接 GitHub:https://github.com/re ...
- Linux系统下设置vi编辑器,tab键为4
1.cd ~ 2.vi .exrc 3.set tabstop=4(保存并退出)即可
- mysql数据库导出导入
MYSQL的命令行模式设置: 我的电脑->属性->高级系统设置->环境变量->系统变量-> 选择Path,在后面添加“;path\mysql\bin;”其中path为MY ...
- mysql查询排名
student_work表 student_info表 sql语句:按grade从高到低排名 结果:
- c网购物车流程图
1. 流程图 2. 流程介绍 1) 客人浏览模式下(未登录状态)加入购物车 这个时候回校验一下商品的可售数量,以及状态等等,校验成功后会保存到cookie和memcache,数据操作校验以memcac ...
- Android 网络连接状态的监控
有些应用需要连接网络,例如更新后台服务,刷新数据等,最通常的做法是定期联网,直接使用网上资源.缓存数据或执行一个下载任务来更新数据. 但是如果终端设备没有连接网络,或者网速较慢,就没必要执行这些任务. ...
- csu1364 Interview
对拍了一波才找到的错误,此题我用的是二分答案加倍增查询,实际上query那里我觉得仍然有缺陷,因为每一次我的查找还是在循环找到一个k使得x+2^k <= y,而错的地方也正在此地,一开始没有判断 ...