如何改变每5秒的背景 [英] How to change background on every 5s

查看:103
本文介绍了如何改变每5秒的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将图像 background.jpg 作为背景。每隔10秒,如何加载一个新的背景 background_n.jpg ,它会停留100毫秒,然后回到 background.jpg 和那么?

I have image background.jpg as the background. Every 10s, how to load a new background background_n.jpg which stays for 100ms and then back to background.jpg and so on?

推荐答案

function change_background( new_image_source ) {

  var myimage = $( '#myimage' );

  myimage.attr( 'src', new_image_source );

  setTimeout( function () {

    change_background( 'new image source here' );

  }, 10000);

}

这篇关于如何改变每5秒的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆