<script>
var arr = function(){
return new arr.prototype.init();
}
arr.prototype.init = function(){//介质
return this;
}
arr.prototype.ded1 = function(){
console.log(1);
return this;
}
arr.prototype.ded2 = function(){
console.log(2);
return this;
} arr.prototype.init.prototype = arr.prototype;
arr().ded1().ded2();
</script>
arr.prototype.init.prototype = arr.prototype;关键步骤

(function(){
var jQuery = function(){
return new jQuery.fn.init();
} jQuery.fn = jQuery.prototype = {
constructor : jQuery,
init : function(){
return this;
},
say : function(){
console.log('say:hello');
return this;
},
tell : function(){
console.log('tell:hello');
return this;
}
} jQuery.fn.init.prototype = jQuery.prototype; jQuery().tell();
jQuery().say();
console.log( jQuery() );
console.log( jQuery.fn );
console.log( jQuery.prototype );
})()

 

jQuery链式调用的更多相关文章

  1. mark jquery 链式调用的js原理

    我们在使用jquery的时候会用到类似$("#id").css('color','red').show(200); 这样写有点减少代码量,减少了逐步查询DOM的性能损耗: js 原 ...

  2. JavaScript设计模式-8.链式调用

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. jQuery的XX如何实现?——2.show与链式调用

    往期回顾: jQuery的XX如何实现?——1.框架 -------------------------- 源码链接:内附实例代码 jQuery使用许久了,但是有一些API的实现实在想不通.于是抽空看 ...

  4. 如何写 JS 的链式调用 ---》JS 设计模式《----方法的链式调用

    1.以$ 函数为例.通常返回一个HTML元素或一个元素集合. 代码如下: function $(){ var elements = []; ;i<arguments.length;i++){ v ...

  5. js实现方法的链式调用

    假如这里有三个方法:person.unmerried();person.process();person.married();在jQuery中通常的写法是:person.unmerried().pro ...

  6. javascript学习(10)——[知识储备]链式调用

    上次我们简单的说了下单例的用法,这个也是在我们java中比较常见的设计模式. 今天简单说下链式调用,可能有很多人并没有听过链式调用,但是其实只要我简单的说下的话,你肯定基本上都在用,大家熟知的jQue ...

  7. 仿jQuery之链式调用

    链式调用的形式其实就是对象调用一连串的方法.为什么能连续调用这么多的方法?因为调用方法返回调用的对象,于是乎就可以一如既往,一往无前地调用下去.链式调用的原理就是在方法中返回执行上下文this,每次调 ...

  8. 玩一把JS的链式调用

    链式调用我们平常用到很多,比如jQuery中的$(ele).show().find(child).hide(),再比如angularjs中的$http.get(url).success(fn_s).e ...

  9. JavaScript链式调用

    1.什么是链式调用? 这个很容易理解,例如 $('text').setStyle('color', 'red').show(); 一般的函数调用和链式调用的区别:链式调用完方法后,return thi ...

随机推荐

  1. chrome 常用插件下载安装

    可在google的应用商店进行下载:chrome://apps/ 但大多时间无法链接. 国内插件下载地址: http://www.cnplugins.com http://chromecj.com/ ...

  2. 10 python 封装----@property的用法

    1.基本概念 在python中用双下划线开头的方式将属性隐藏起来(设置成私有的) #其实这仅仅这是一种变形操作 #类中所有双下划线开头的名称如__x都会自动变形成:_类名__x的形式: class A ...

  3. 为什么NoSql快--磁盘顺序写

    数据写入方式 1.  update-in-place原地更新 2.  append-only btree/copy on write tree顺序文件末尾追加   数据被按照特定方式放置,提升读性能, ...

  4. linux 安装禅道

    1. 查看Linux服务器版本信息 # cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) 2. 禅道开源版安装包下载 # wge ...

  5. 数据类型-DataFrame

    数据类型-DataFrame DataFrame是由多个Series数据列组成的表格数据类型,每行Series值都增加了一个共用的索引 既有行索引,又有列索引 行索引,表明不同行,横向索引,叫inde ...

  6. vs2010+Aspx进行sharepoint2010工作流开发(3) 资料整理

    http://www.cnblogs.com/janet/archive/2010/04/24/1719315.html http://www.cnblogs.com/poissonnotes/arc ...

  7. java线程状态及转换

    java线程有6种状态: 新建线程new,启动线程runnable,阻塞block,限时等待timed_waiting,等待线程waiting,终止线程terminated 1.限时等待timed w ...

  8. Clustered Index & Non Clustered Index(聚簇索引和非聚簇索引)

    每个表只能有一个聚簇索引,而能有200多个非聚簇索引. 在物理分配上, 每个表的数据都是分配在页上,一个页大概有8k左右,假设一条数据占1000字节的话,那么8000条数据占8000*1k/8k = ...

  9. [leetcode]238. Product of Array Except Self除了自身以外的数组元素乘积

    Given an array nums of n integers where n > 1,  return an array output such that output[i] is equ ...

  10. requestFullscreen()事件全屏不好使怎么解决

    标明:我在360和火狐中全屏requestFullscreen()事件不好使: 解释:我后来发现我的页面是在iframe框架中使用的并且没有设置allowfullscreen="true&q ...