JavaScript实现鼠标效果

<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style type="text/css">
    #div1 {
        width: 100px;
        height: 100px;
        background: red;
    }
</style>

<script>
    function togreen(){
    var green=document.getElementById('div1');
    green.style.width='200px';
    green.style.height='200px';
    green.style.background='green';
    }
    function tored() {
    var green=document.getElementById('div1');
    green.style.width='100px';
    green.style.height='100px';
    green.style.background='red';
    }
</script>

</head>

<body>
<div id="div1" onMouseOver="togreen()" onMouseOut="tored()">
</div>
</body>
</html>

 查看原文

原文地址:https://www.cnblogs.com/xinlvtian/p/7872140.html