So, I wanted to make a bg-image change dynamically the same in this example: link
The background changes every 5 seconds.
Does anyone know how?
So, I wanted to make a bg-image change dynamically the same in this example: link
The background changes every 5 seconds.
Does anyone know how?
You can do it via JavaScript with a timer running every 5 sec. See example:
// initial call, or just call refresh directly
setInterval(AsyncTrocaImg, 5000);
function AsyncTrocaImg() {
$.post(base + "Home/GetNewImg", {}, function (URL) {
$('body').css('background-image', 'url('+URL+')');
}).fail(function () {
console.log("error");
})
}
But be careful with the images, so that your site does not get "heavy".
It would also have some other forms even simple, but this is the way I would do it.
See also if these links help you: