처음 질문을 올렸을 때 실수를했기 때문에이 질문을 다시 게시합니다. 질문하기 전에 충분히 열심히 노력하지 않았습니다. 그리고 저에게 제 일을하도록 요청한 것에 대해 지역 사회에 사과하고 싶습니다.알파벳순으로 항목 정렬
div 안에 정렬되지 않은 목록을 사전 순으로 정렬하려고합니다. 목록 항목의 순서가 지정되지 않은 목록 내부는 아니지만 순서가 지정되지 않은 목록 자체. 내가 같이하기를 원하는
<div class="FindByCategory">
<ul>
<li> B. This is the first list item in the second unordered list</li>
<li> B. This is the second list item in the second unordered list</li>
</ul>
<ul>
<li> A. This is the first list item in the first unordered list</li>
<li> A. This is the second list item in the first unordered list</li>
</ul>
</div>
:
<div class="FindByCategory">
<ul>
<li> A. This is the first list item in the first unordered list</li>
<li> A. This is the second list item in the first unordered list</li>
</ul>
<ul>
<li> B. This is the first list item in the second unordered list</li>
<li> B. This is the second list item in the second unordered list</li>
</ul>
</div>
이것은 내가 지금까지 무엇을했는지된다
이
는 같은 HTML이 모습입니다<script>
function sortUnorderedList(div.FindByCategory, sortDescending) {
if(typeof div.FindByCategory == "string")
div = document.getElementById(div.FindByCategory);
var uls = ul.getElementsByTagName("UL");
var vals = [];
for(var i = 0, l = uls.length; i < l; i++)
vals.push(uls[i].innerHTML);
vals.sort();
for(var i = 0, l = uls.length; i < l; i++)
uls[i].innerHTML = vals[i];
}
$(function(){
FindByCategory()
}
</script>
을보십시오! –