sort

<html>
<head>
    <title>select_sort</title>
    <script type="text/javascript" src="../jquery-1.10.1.js"></script>

</head>
<body>
    <ol id="sort">
        <li>22</li>
        <li>23</li>
        <li>2</li>
        <li>100</li>
    </ol>
    <hr />
    <ol id="result"></ol>
</body>
<script type="text/javascript">
    $(document).ready(function () {
        var minLi;
        $("#sort li").each(function (i) {
            if (i == 0) {
                minLi = $(this).clone();
                $(this).clone().appendTo($("#result"));
            } else {
                if (minLi.html() * 1 >= $(this).clone().html() * 1) {
                    minLi = $(this).clone();
                    $(this).clone().prependTo($("#result"));
                }
                else {
                    $(this).clone().appendTo($("#result"));
                }
            }
        });
    })
</script>
</html>

 

posted @ 2013-09-13 01:35  木由水  阅读(200)  评论(0编辑  收藏  举报