jQuery 根据数字对 DOM 进行排序
以下是重复的类:
<div class="inner">
<p>
Text1
<span class="plus"> 25</span>
<span class="minus">12</span>
</p>
</div>
<div class="inner">
<p>
Text2
<span class="plus"> 205</span>
<span class="minus">2</span>
</p>
</div>
我有两个 href 标签充当排序按钮:
<a href="#" id="pos">Sort by Positive.</a>
<a href="#" id="neg">Sort by Negative.</a>
通过 jQuery,如何重新渲染 dom,并根据按钮单击排序
?
小提琴位于此处。
Following is the class which is repeated:
<div class="inner">
<p>
Text1
<span class="plus"> 25</span>
<span class="minus">12</span>
</p>
</div>
<div class="inner">
<p>
Text2
<span class="plus"> 205</span>
<span class="minus">2</span>
</p>
</div>
I have two href tags to act as sort button:
<a href="#" id="pos">Sort by Positive.</a>
<a href="#" id="neg">Sort by Negative.</a>
Through jQuery, how can I re-render the dom, with the <p>
sorted based on the button click?
The fiddle is located here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类似于:
http://jsfiddle.net/pHyDm/8/
虽然这两个函数基本上是相同并且可以/应该进行一些重构。
Something like:
http://jsfiddle.net/pHyDm/8/
Though the two functions are basically the same and could/should probably be refactored a bit.