鼠标悬停和移除的变化(红变绿)

鼠标悬停和移除

效果图

 

 

 

 

 

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            #div1{
                width:100px;
                height:100px;
                background-color:red;
                border-radius:20px;
                margin:0 auto;
            }
                
            
            
            
        </style>
    </head>
    <body>
        <div id="div1" onmouseover="toGreen()" onmouseout="toRed()"></div>
        <script>
            function toRed()
            {var x=document.getElementById("div1");
                x.style.width="100px";
                x.style.height="100px";
                x.style.backgroundColor="red";
                x.style.borderRadius="20px";
                
                
            }
            
            function toGreen()
            {var v=document.getElementById("div1");
             v.style.width="300px";
             v.style.height="300px";
             v.style.backgroundColor="green";
             v.style.borderRadius="30px";
                
                
                
            }
            
            
            
        </script>
        
    </body>
</html>

鼠标悬停onmouseover在红色上面,变成绿色,鼠标移开onmouseout变红色

 

posted @ 2020-07-05 14:13  正好00  阅读(496)  评论(0编辑  收藏  举报