Javascript代码:
<script type="text/javascript">
function react() {
document.getElementById("img").src = second.jpg
}
</script>
网页:
<div style="width:170px;height:160px;border:2px solid blue">
<img src="first.jpg" style="width:inherit;height:inherit" id="img" onload="setTimeout('react()', 15000)"/>
</div>
请注意,图像中的图像不会改变,因为它是在 setTimeout() 函数设置的 15000 毫秒内从 first.jpg 变为 second.jpg