The code below will, if put in the HEAD of a page, move all LI-items that contains a
-tag to the bottom of the list. Handy for TODo-lists.
<script type="text/javascript">
function organizeList(list) {
var listItems = list.getElementsByTagName("LI");
var len = listItems.length;
for (var i = 0;i<len;i++) {
if (listItems[i].getElementsByTagName("DEL").length > 0) {
list.appendChild(listItems[i]);
i--;
len--;
}
}
}
window.onload = function() {
var lists = document.getElementsByTagName("UL");
for (var i = 0;i<lists.length;i++) {
organizeList(lists[i]);
}
}
script>