最简单的JS例子2

当您在例子中的输入域中键入字符时,字符会被更改为大写(逐一地):

<html>

<head>
<script type="text/javascript">
function upperCase(x)
{
var y=document.getElementById(x).value
document.getElementById(x).value=y.toUpperCase()
}
</script>
</head>

<body>
	
输入您的姓名: <input type="text" id="fname" onkeyup="upperCase(this.id)" />

</body>
</html>

输出:

输入您的姓名: 






原文地址:https://www.cnblogs.com/tangbinghaochi/p/6293189.html