<button onClick="return rn()">随机生成名字</button>
<span id="target"></span>
<script>
function rn(){
//这个名字库只能自己填充内容了,js没这么智能,可以自己拼个名字出来...
var store = ['Marry','Jhon','Tom','Lily'],
el = document.getElementById('target')
return el.innerHTML = store[Math.floor(Math.random()*store.length)]
}
</script>
在吗?你是输入每个单词后,排你是哪个意思,有问题再来找我。
<html>
<body>
<script type="text/javascript">
function SortNames(){
var index = 0
var names = new Array()
t = document.getElementById('in').value
m=t.split("")
m.sort()
document.getElementById("sorted").value=m.join("\n")
}
</script>
<form method="post" action="">
<input type = "text" id ="in">
<input type = "button" value ="add" onclick = "SortNames()">
<textarea cols = "60" rows = "10" name = "sorted">
</textarea>
</form>
</body>
</html>