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

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

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

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

下面的JS代碼可以動(dòng)態(tài)修改圖片地址,以顯示一張新的圖片,實(shí)際上是通過(guò)修改圖片的src屬性來(lái)實(shí)現(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>

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

相關(guān)文章

最新評(píng)論