1document.getElementById('Demo').style.backgroundImage = "url('Test.png')";
1function bg() {
2
3 var imgCount = 3;
4 var dir = 'http://local.statamic.com/_themes/img/';
5 // I changed your random generator
6 //floor: helps getting a random integer
7 var randomCount = (Math.floor(Math.random() * imgCount));
8 // I changed your array to the literal notation. The literal notation is preferred.
9 var images = ['001.png', '002.png', '003.png'];
10 // I changed this section to just define the style attribute the best way I know how.
11 document.getElementById('banner').setAttribute("style", "background-image: url(" + dir + images[randomCount] + ");background-repeat: no-repeat;background-size: 388px 388px");
12}
13// Don't forget to run the function instead of just defining it.
14bg();