例子,大小写字母转换代码:
 
复制代码 代码示例:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> 
<html> 
<head> 
<title>系统学堂 - www.osxue.com </title> 
</head> 
<script> 
function a(){ 
  document.getElementById("test").value = document.getElementById("test").value.toUpperCase(); 
} 
function b(){ 
  document.getElementById("test2").value = document.getElementById("test2").value.toLowerCase(); 
} 
</script>
<body> 
输入小写,会自动转为大写:<input type=text id=test onkeyup="a()"><br/> 
输入大写,会自动转为小写:<input type=text id=test2 onkeyup="b()"> 
</body> 
</html>