我如何在javascript或jquery中按维度对图像进行排序 [英] How I can sort images by dimension in javascript or jquery

查看:66
本文介绍了我如何在javascript或jquery中按维度对图像进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在JavaScript或jQuery中按维度对图像进行排序。我的代码如下:

How I can sort images by dimension in JavaScript or jQuery. My code is following:

var imgsrc = '';
if (document.images.length < 1) {
    alert('No images to open');
    return;
}
for (var i = 0; i < window.parent.document.images.length; i++) {
    imgsrc + = '\n';
}

if (imgsrc != '') {
    var newwin = window.open('', '');
    newwin.document.open();
    newwin.document.write('\n' + imgsrc + '');
    newwin.document.close();
} else {
    alert('No images!')
}​

请帮帮我。提前谢谢。

推荐答案

参见此处。您可以对等数组进行排序。 .sort()有一个带有sort函数的重载。那是你比较尺寸的地方。

See here for getting image dimensions. You can sort an array like this. .sort() has an overload that takes a sort function. That is where you would compare the sizes.

这篇关于我如何在javascript或jquery中按维度对图像进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆