2013-03-15 51 views
0

我剛剛在html上添加了這樣的圖像。如何更改鼠標懸停的圖標

<img src="Your image address" width="500" height="500"> 

但我想結束意味着添加鼠標時鼠標光標來到圖像,然後圖像應該改變,我用什麼代碼在這裏。由於

+0

http://www.w3schools.com/jsref/event_onmouseover.asp – David 2013-03-15 13:22:02

回答

0

文件層次:Vidzpra/index.html,然後Vidzpra /圖片有兩個圖像black.jpg和yellow.jpg 下面的代碼(HTML與JavaScript的內部)上改變鼠標的圖像:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>onMouserOver Img change</title> 

<script> 
    function changeImg(el){ 
     el.src = "images/yellow.jpg"; 
    } 

    function fixImg(el){ 
     el.src = "images/black.jpg"; 
    } 

</script> 
</head> 

<body> 
    <div> 
     <img onmouseover="changeImg(this)" onmouseout="fixImg(this)" border="0" src="images/black.jpg" alt="" align="middle" > 
    </div> 
</body> 

</html> 
+0

謝謝你解決我的問題。 – 2013-03-16 05:52:07

相關問題