欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS動態(tài)修改圖片的URL(src)的方法

 更新時間:2015年04月01日 11:07:45   作者:瘋狂一夏  
這篇文章主要介紹了JS動態(tài)修改圖片的URL(src)的方法,涉及javascript操作圖片src屬性的技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了JS動態(tài)修改圖片的URL(src)的方法。分享給大家供大家參考。具體如下:

下面的JS代碼可以動態(tài)修改圖片地址,以顯示一張新的圖片,實際上是通過修改圖片的src屬性來實現(xiàn)的

<!DOCTYPE html>
<html>
<head>
<script>
function changeSrc()
{
document.getElementById("myImage").src="hackanm.gif";
}
</script>
</head>
<body>
<img id="myImage" src="compman.gif" width="107" height="98">
<br><br>
<input type="button" onclick="changeSrc()" value="Change image">
<p><b>Note:</b> The src property can be changed at any time. 
However, the new image inherits the height and width
attributes of the original image,
if not new height and width properties are specified.</p>
</body>
</html>

希望本文所述對大家的javascript程序設(shè)計有所幫助。

相關(guān)文章

最新評論