码迷,mamicode.com
首页 > 编程语言 > 详细

js json排序

时间:2016-08-16 19:53:23      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

var p = [

            {name:"kitty", age:12},
            {name:"sonny", age:9},
            {name:"jake", age:13},
            {name:"fun", age:24}
        ]
        function down(x, y) {
            return (x.age < y.age) ? 1 : -1
 
        }
        p.sort(down)
        var $text = "<div>"
        $.each(p, function (key, value) {
            var $div = "<div>"
            $.each(value, function (key, value) {
                $div += "<span>" + key + ":</span>" "<span>" + value + "</span>" "         "
            })
            $div += "</div>"
            $text = $text + $div
        })
        $text += "</div>"
 
 
 
        $(".text").html($text)

js json排序

标签:

原文地址:http://www.cnblogs.com/blueskycc/p/5777500.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!