jQuery源码历代记5
?
之前文章传送门:http://adamed.iteye.com/category/207898
?
下面要介绍的jQuery构造器中的方法是入栈、出栈方法:
?他们分别是pushStack和end。
先看下putStack的API描述
.pushStack( elements )
elements? An array of elements to push onto the stack and make into a new jQuery object.?
?
?
pushStack : function( a , args ) { //这里a为数组:['<em>aaa</em>','<em>aaa</em>'] //这里的args为:'em' var fn = args && args[args.length - 1]; //这里的fn为'em' if ( !fn || fn.constructor != Function ) { //fn符合此判断 if ( !this.stack ) this.stack = [ ]; //将原结果集3个p元素存放至this.stack this.stack.push( this.get() ); //将结果集更新为2个新em元素的内容 this.get( a ); }}?//**********************这是分隔符********************************
我们下面用大量的篇幅阐述一下jQuery.find的源码~~?
?
未完待续~~~
?
1 楼 zhangwenzhuo 2012-04-02 为什么this.get()会返回本身的呢?