JS使用oumousemove和oumouseout動態(tài)改變圖片顯示的方法

字號:


    本文實例講述了JS使用oumousemove和oumouseout動態(tài)改變圖片顯示的方法。分享給大家供大家參考。具體如下:
    鼠標(biāo)放到圖片上時圖片會自動變大,鼠標(biāo)離開圖片還原
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function bigImg(x)
    {
    x.style.height="64px";
    x.style.width="64px";
    }
    function normalImg(x)
    {
    x.style.height="32px";
    x.style.width="32px";
    }
    </script>
    </head>
    <body>
    <img onmouseover="bigImg(this)" onmouseout="normalImg(this)"
    border="0" src="smiley.gif" width="32" height="32">
    <p>The function bigImg() is triggered when the user moves
    the mouse pointer over the image.</p>
    <p>The function normalImg() is triggered when the mouse
    pointer is moved out of the image.</p>
    </body>
    </html>