Image src 属性

定义和用法
src 属性可设置或者返回图片的 src 属性值。
src 属性指定了一个图的 URL。
语法
imageObject.src=URL
浏览器支持
所有主要浏览器都支持 src 属性
实例
实例
<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">
</body>
</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">
</body>
</html>
尝试一下 »

更多建议: