jQuery pushStack(jQuery 推送堆栈)
问题描述
我需要一些帮助来理解 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 推送堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQuery 推送堆栈
- 失败的 Canvas 360 jquery 插件 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Flexslider 箭头未正确显示 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
