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 推送堆栈
基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
