小编joe*_*joe的帖子

如何根据他们的ID对LI进行排序

尝试一堆没有可行结果的解决方案.我有代码获取跨度的值并为LI创建一个ID.然后我想根据LI的ID对这些LI的DESCENDING进行排序.救命?谢谢!

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<ul id="dumb">
    <li>cello<span>2987</span></li>
    <li>zello<span>1723</span></li>
    <li>aello<span>3476</span></li>
</ul>
<script type='text/javascript' src='JQUERY INCLUDE'></script> 
<script type="text/javascript"> 
$(document).ready(function() {
    $('ul li span').each(function(){
        var pubValue = $(this).html();
        $(this).parent().attr('id', pubValue);
    });
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html sorting jquery

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

html ×1

jquery ×1

sorting ×1