簡體   English   中英

IMG SRC不起作用

[英]Img src doesn't work

我寫了這個簡單的javascript代碼,使用Timeout更改了圖像src,但它根本不起作用。 我的錯誤在哪里?

    <script type="text/javascript">
      function titoloanimato()
         {setTimeout (
              function () {document.getElementById("titoloanimato").src = "grafica/titolo_animato_1b.gif"},1000)
         }
    </script>
    </div>

謝謝!

嘗試以下代碼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)
         }

演示: http//jsfiddle.net/RhxZ6/6/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM