x
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>蜜蜂教程(mifengjc.com)</title>
6
</head>
7
<head>
8
<script>
9
function myFunction() {
10
var x = document.getElementById("fname");
11
x.value = x.value.toUpperCase();
12
}
13
</script>
14
</head>
15
<body>
16
17
输入你的名字: <input type="text" id="fname" onchange="myFunction()">
18
<p>当你离开输入框后,函数将被触发,将小写字母转为大写字母。</p>
19
20
</body>
21
</html>