how to change the background image using javascript else if in javascript code example
Example: set an attribute background image javascript
function bg() {
var imgCount = 3;
var dir = 'http://local.statamic.com/_themes/img/';
var randomCount = (Math.floor(Math.random() * imgCount));
var images = ['001.png', '002.png', '003.png'];
document.getElementById('banner').setAttribute("style", "background-image: url(" + dir + images[randomCount] + ");background-repeat: no-repeat;background-size: 388px 388px");
}
bg();