-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace.js
More file actions
24 lines (20 loc) · 712 Bytes
/
replace.js
File metadata and controls
24 lines (20 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
pictures = ['URL-TO-IMAGE.JPG', 'URL-TO-IMAGE2.PNG']
var picture = '',
images = document.getElementsByTagName('img');
function replace_image() {
for (var i = 0; i < images.length; i++) {
rand = parseInt(Math.random() * pictures.length);
picture = pictures[rand];
images[i].setAttribute('src', picture);
images[i].setAttribute('srcset', picture);
}
var picture = '',
banners = document.getElementsByTagName('banner');
for (var i = 0; i < banners.length; i++) {
rand = parseInt(Math.random() * pictures.length);
picture = pictures[rand];
banners[i].setAttribute('style', 'background-image: url('+picture+');');
}
}
replace_image();
setInterval(replace_image, 1000);