问题描述
我需要一些帮助来理解 pushStack
I need some help to understand pushStack
这里我做了一个例子,使用与否的结果是一样的http://jsfiddle.net/Bz5n9/2/ 所以我想我真的不明白它的用途.
Here I've made an example where the results using it or not are the same http://jsfiddle.net/Bz5n9/2/ so I think i really didn't get what is it for.
谢谢!
推荐答案
您当前正在添加到集合中,将一个新集合推送到堆栈上,该集合已经是结果(您可以只返回 this.添加()).它所做的不是将 .b 元素作为新元素推送到堆栈上,而是推送带有 .b 元素 和 的新集合#2 <li> 你开始用的.
You're currently adding to the collection, pushing a new collection on the stack that's already the result (you could just return the result of this.add()). What this does is instead of pushing .b elements on the stack as a new element, it pushes a new set with .b elements and the #2 <li> you started with.
相反,您应该直接传递元素(没有 .add() 调用),像这样:
Instead, you instead should pass the elements directly (no .add() call), like this:
return this.pushStack(newCollection, "agregate", "");
你可以在这里测试一下.
这篇关于jQuery 推送堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)