How to make background color of div tag keep changing using JQuery?

前端 未结 3 1954
再見小時候
再見小時候 2020-12-21 07:59

I am trying to change background of div tag continuously using for loop and rgb() values . following is my code written in sample.html:

    

        
3条回答
  •  盖世英雄少女心
    2020-12-21 08:53

    You can use .setInterval()

    Enclose your code within a function called animate

    var intervalID = window.setInterval(animate, 500);
    

    Not sure correct this

    $("#sqr").css("background-color","rgb(" + r +"," +g+"," +b +")");
    

提交回复
热议问题