当前位置: 代码迷 >> JavaScript >> jQuery有内置的倒序功能吗?解决思路
  详细解决方案

jQuery有内置的倒序功能吗?解决思路

热度:76   发布时间:2012-05-27 05:42:30.0
jQuery有内置的倒序功能吗?
下面这段代码肯定是a\b\c顺序显示,能不能简单的处理为显示c   b   a?
$( 'li ')有没有简单的排序方法?each能不能运行倒序?

[code=HTML]
<ul>
        <li> a </li>
        <li> b </li>
        <li> c </li>
</ul>
<script   type= "text/javascript "   src= "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js "> </script>
<script   type= "text/ecmascript ">
$( 'li ').each(function(){
alert($(this).html());
});
</script>
[/code]

------解决方案--------------------
$('ul> li').get().sort(function(first,second)
{
//在这写你的按什么排序
});
  相关解决方案