Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Sorting Unordered Lists inside a Div using Javascript?
I'm very new to javascript. I'm trying to write a simple script to order alphabetically on load a series of UL's. Not the LI's inside of the UL's, but the UL's themselves.
Here is what the HTML looks like:
<div class="FindByCategory">
<ul>
<li>This is the first list item in the first unordered list</li>
<li>This is the second list item in the first unordered list</li>
</ul>
<ul>
<li>This is the first list item in the second unordered list</li>
<li>This is the second list item in the second unordered list</li>
</ul>
</div>
This is what I have so far:
<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];
}
</script>
2 Answers
- Anonymous9 years agoFavorite Answer
Here's the guide: http://stackoverflow.com/questions/1535744/sort-un...
- kimmonsLv 45 years ago
i imagine i'd use CSS to finish this extremely of java script. try something like: #established { position: absolute; history-shade: #00FF33; history-image: url(azflag.gif) history-position: center center; history-repeat: no-repeat; proper: 40 5%; bottom: 40 5%; left: 40 5%; excellent: 40 5%; } Edit to respond to comments: I made the history image center via including positional statements as shown above. history-image: url(azflag.gif); history-position: center center; history-repeat: no-repeat;