How to cycle the background-image for the body tag?
function changeBg() { $("body").css("background","red"); $("body").css("background","green"); } changeBg(); setInterval(changeBg, 3000); How to cycle the background-image for the body tag?
function changeBg() { $("body").css("background","red"); $("body").css("background","green"); } changeBg(); setInterval(changeBg, 3000); Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
setInterval(changeBody, 3000); function changeBody() { $('body').css('background-color') == "rgb(255, 0, 0)" ? $('body').css('background', 'yellow') : $('body').css('background', 'red'); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> </script> changeBody(); function changeBody(i) { var colors = ['red', 'green', 'blue', 'yellow']; if(typeof(i) == 'undefined' || i > colors.length) i = 0; $('body').css('background-color', colors[i]); setTimeout(changeBody, 2000, i+1); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> </script> Source: https://ru.stackoverflow.com/questions/538466/
All Articles