为什么改成class就改变不了样式了呢,用的是getElementByClassName,求大神解释
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> 光标聚焦事件 </title>
<script type="text/javascript">
function message(){
var bg=document.getElementById("bg");
bg.style.backgroundColor="pink";
}
function message1(){
var bg1 = document.getElementById("bg");
bg1.removeAttribute('style');
}
</script>
</head>
<body>
请选择您的职业:<br>
<form>
姓名:<input id="bg" type="text" onfocus="message()" onBlur="message1()" />
</form>
</body>
</html>