Javascript 使用JS/jQuery在前端对HTML div进行排序
考虑以下表示产品审查的Javascript 使用JS/jQuery在前端对HTML div进行排序,javascript,jquery,html,asp.net-mvc,Javascript,Jquery,Html,Asp.net Mvc,考虑以下表示产品审查的HTML块(为简洁起见省略内容): 如果没有,什么是实现这一目标的适当方式 谢谢 这些论文可能会有帮助 谢谢,Gareth,我建议使用我的jQuery插件 用它填充具有排序的列表 var list = $("ul#people").repeatable(); // declaring the repeatable data.sort(sortFunction); // sort the data in the way you want list.valu
HTML
块(为简洁起见省略内容):
如果没有,什么是实现这一目标的适当方式
谢谢 这些论文可能会有帮助 谢谢,Gareth,我建议使用我的jQuery插件 用它填充具有排序的列表
var list = $("ul#people").repeatable(); // declaring the repeatable
data.sort(sortFunction); // sort the data in the way you want
list.value = data; // that's data population, sic!
您尝试查看Angular的ng repeat并使用它的排序算法进行此操作?@vimes1984我更希望避免添加额外的JS LibrariesAsy,只需获取元素,使用
sort()
对它们进行排序,然后将它们追加回来again@adeneosort()
是否适用于所有类型(例如,在我的情况下,排序日期或评级)或者每种类型都需要显式实现吗?sort()
有一个回调函数,在这个函数中,您可以按照自己的方式进行排序
1. loop through every "review-item" in "reviews" and store it in a collection
2. sort the collection based on a particular property of "review-item"
3. clear the "reviews" div and append the collection to it
var list = $("ul#people").repeatable(); // declaring the repeatable
data.sort(sortFunction); // sort the data in the way you want
list.value = data; // that's data population, sic!