HTML——输入小写字母 鼠标移开变为大写字母,并给输入框添加焦点事件

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
input:focus{
background-color:yellow ;
}
</style>
</head>
<body>
<div>
<p>请输入英文字母:<input type="text" onchange="myFunction()" id="fname" value="" /></p>
<script type="text/javascript">
function myFunction() {
var x=document.getElementById("fname");
x.value=x.value.toUpperCase();
}
</script>
</div>
</body>
</html>

posted @ 2017-12-18 14:04  燕林夕  阅读(688)  评论(0编辑  收藏  举报