如何在Javascript中按字母顺序对图像进行排序 [英] How Do I Sort Images By Alphabetical Order In Javascript

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

问题描述

我有一个显示在div内容中的图像列表,带有排序按钮,当用户点击排序按钮时,所有图像必须按照字母顺序排列...我在java脚本中尝试了很多来实现这一点,...但.. :(我无法实现这个



我会非常感谢任何回复...:)

解决方案

嗨使用以下



var images = [,,,]; //这里放置你的图像名称

images.sort(); //使用javascript的排序功能。



谢谢,

Mukesh

使用 sort 功能

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_sort [ ^ ]



参考:



http://stackoverflow.com/questions/13168657/how-to-sort-div-content -in-descending-order-by-image-name [ ^ ]





http://stackoverflow.com/ question / 12814212 / how-to-sort-by-image-src-name-for-all-li-under-a-ul [ ^ ]


I have a list of images displaying in a div content, with sort button,when user clicks sort button all the images must be arranged according to their alphabetical ...i had tried much in java script to achieve this,..but ..:( i cannot achieved this

I will be very thankful for any reply ...:)

解决方案

Hi use following

var images = ["", "", "", ""];// here place your image names
images.sort();// use sort function of javascript.

Thanks,
Mukesh


use sort function
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_sort[^]

Refer this:

http://stackoverflow.com/questions/13168657/how-to-sort-div-content-in-descending-order-by-image-name[^]


http://stackoverflow.com/questions/12814212/how-to-sort-by-image-src-name-for-all-li-under-a-ul[^]


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

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