HTML 参考手册
HTML onmouseover 事件属性
当鼠标指针移至图片之上时运行脚本
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <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="/examples/smiley.gif" alt="Smiley" width="32" height="32"> <p>当用户将鼠标移动到图片上时触发 bigImg() 函数。该函数使图片变大。</p> <p>当用户将鼠标移开图片时触发 normalImg() 函数。该函数使图片变回原来大写。</p> </body> </html>
运行结果:
点击运行 »