对元素的一个列表按字母排序
<script>
function sortkids(e){
if(rypeof e=="string"){e = document.getElementById(e)}
var kids = []
for(var x = e.firstChildx!=nullx = x.nextSibling){
if(x.nodeType == 1/*Node.ELEMENT_NODE*/){
kids.push(x)
}
}
kids.sort(function(n,m){
var s=n.firstChild.data
var t=m.firstChild.data
if(s<t){return -1}
else if(s>t){return 1}
else{return 0}
})
for(var i=0i<kids.lengthi++){
e.appendChild(kdis[i])
}
}
</script>
<ul id="list">
<li>one</li><li>two</li><li>three</li><li>four</li>
</ul>
<button onclick="sortkids('list')">Sort list</button>
----------------------------------------------------------------------------------------------------
《Javascript 权威指南》
你是css3吗?可以用writing-mode: tb-rl例子:
<html>
<head>
<style type="text/css">
div.one
{
height:300px
writing-mode: tb-rl
}
</style>
</head>
<body>
<div class="one">Some text. Right-to-left direction111111111111.</div>
</body>
</html>