JS 快速获取数据中的最大、最小值

var  numbers = [5, 458 , 120 , -215 , 228 , 400 , 122205, -85411];
var maxInNumbers = Math.max.apply(Math, numbers);
var minInNumbers = Math.min.apply(Math, numbers);

栗子

$(document).ready(function () {
    //footer-guide dl 宽度
    var dlLength = $('.footer-guide dl').length;
    var dlNum = (100/dlLength);
    var dlHeight = [];
    $('.footer-guide dl').each(function(i,e){
    	dlHeight.push($(e).height());
    });
	var maxHeight =  Math.max.apply(Math, dlHeight);
    if(dlLength<=7){
    	$('.footer-guide dl').css('width',dlNum+'%')
    }else{
    	$('.footer-guide dl').css({'width':'14.28%','height':maxHeight});
    }
});
THE END
分享
二维码
打赏
< <上一篇
下一篇>>