Change Background Color CSS with Timer JQuery

后端 未结 2 1523
情话喂你
情话喂你 2020-12-10 20:53

I was hoping someone could show me efficient JQuery to animate between 4 background colors in a div class.

I would like these events to be triggered by time, not cli

2条回答
  •  没有蜡笔的小新
    2020-12-10 21:45

    UPDATE

    I'm sure there are better ways to do this, but just to show you a simple way of accomplishing this...

    http://jsfiddle.net/UnsungHero97/QLPbW/5/


    You want to use the window.setInterval() function...

    window.setInterval(rotateBG, 1000); // 1000 = 1 second
    
    function rotateBG() {
        // logic to rotate background
    }
    

    I hope this helps.

提交回复
热议问题