dtpyvb1873 2013-04-17 18:49
浏览 23

在javascript倒计时器之后更改图像一次

I'm new to Javascripting - infact, I'm not I just having done any for ages.

I'm trying to change and image once using a function at the end of a javascript countdown. In the countdown script it says I can specify a function to call on complete.

onComplete      : changeImage,

So, at the bottom of the javascript countdown timer, I wrote this:

function changeImage(a) {document.getElementById("img").src=a.src;}
</script>

The image I want to change is above the script, written here:

<a href="index.php"><img id="img" align="middle" height="450" src="images/samandwill.gif" class="logo" /></a>

I want to change the image src to "images/samandwill2.gif"

How can I do this? - I'm using Dreamweaver and PHP.

This is probably totally simple, but I'd be very grateful for some help. All I can find is answers for onclick functions, which is not what I want.

I'd really appreciate some help!

Thanks!

Will

  • 写回答

3条回答 默认 最新

  • douganbi7686 2013-04-17 18:57
    关注

    JSBin example

    use setTimeout to trigger your code after a set time:

    setTimeout(function(){
      document.getElementById('img').src="http://placehold.it/200x200";
    }, 2000);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据