使用Js的對象屬性能實現簡單的翻轉效果。通過onMouseover事件和onMouseOut事件就能實現鼠標移到鏈接上和移開鏈接發生反應。給兩個圖片加上鏈接實現都能翻轉的效果。
reverse.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>圖片翻轉Demo</title>
<style type="text/css">
h1{color:yellow;
text-align:center;}
</style>
</head>
<body>
<h1>實現圖片翻轉</h1>
<img src="smile.jpg" name="smileimage"
onMouseOver="window.document.smileimage.src='smilereverse.jpg';"
onMouseOut="window.document.smileimage.src='smile.jpg';"
>
<br>
<p>
<a href="#"
onMouseOver="window.document.smileimage.src='smilereverse.jpg';"
onMouseOut="window.document.smileimage.src='smile.jpg';"
><img src="submit.png" name="turn" border="0" width="298" height="68"></a>
</p>
</body>
</html>
