I wrote this simple javascript code to change an image src using Timeout, but it doesn't work at all. Where is my mistake?
<script type="text/javascript">
function titoloanimato()
{setTimeout (
function () {document.getElementById("titoloanimato").src = "grafica/titolo_animato_1b.gif"},1000)
}
</script>
</div>
Thank you!
Try below code HTML
<div><img src="" id="img" /></div>
<input type="button" value="set" onclick="titoloanimato()">
Javascript
function titoloanimato()
{setTimeout (
function () {document.getElementById("img").src = "<image url>"},1000)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.