日期:2014-05-16 浏览次数:20463 次
(function($){ $.fn.print_r = function(json){ return $(this).each(function(e){ $(this).html(_print_r(json)); }) } function _print_r(theObj) { var retStr = ''; if (typeof theObj == 'object') { retStr += '<div style="font-size:12px;">'; for (var p in theObj) { if (typeof theObj[p] == 'object') { retStr += '<div><b>['+p+'] => ' + typeof(theObj) + '</b></div>'; retStr += '<div style="padding-left:25px;">' + _print_r(theObj[p]) + '</div>'; } else { retStr += '<div>['+p+'] => <b>' + theObj[p] + '</b></div>'; } } retStr += '</div>'; } return retStr; } $.print_r = function(json){ return _print_r(json); } })(jQuery);
jQuery("#选取一个div的ID").print_r(deptList);