</head>
<style>
#div1{
width:200px;
height:200px;
background-color:red;
}
</style>
<script language="javascript">
function toGreen(){//函数使div变为绿色
document.getElementById('div1').style.width='300px';//切记,不要写成width:300px
document.getElementById('div1').style.height='300px';
document.getElementById('div1').style.background='green';
}
function toRed(){//函数使div变为红色
document.getElementById('div1').style.width='200px';
document.getElementById('div1').style.height='200px';
document.getElementById('div1').style.background='red';
}
</script>
<body>
<div id="div1" οnmοuseοver="toGreen()" οnmοuseοut="toRed()"></div>//onmouseover,onmouseout鼠标事件
</body>
</html>
<style>
#div1{
width:200px;
height:200px;
background-color:red;
}
</style>
<script language="javascript">
function toGreen(){//函数使div变为绿色
document.getElementById('div1').style.width='300px';//切记,不要写成width:300px
document.getElementById('div1').style.height='300px';
document.getElementById('div1').style.background='green';
}
function toRed(){//函数使div变为红色
document.getElementById('div1').style.width='200px';
document.getElementById('div1').style.height='200px';
document.getElementById('div1').style.background='red';
}
</script>
<body>
<div id="div1" οnmοuseοver="toGreen()" οnmοuseοut="toRed()"></div>//onmouseover,onmouseout鼠标事件
</body>
</html>