html - Get Different Images from one URL -
for example,
http://placeimg.com/640/480/people
is 1 url. if reload page, comes new image. website has background image, , want random image of 2 images:
how can achieve this? , calling of image in css.
in javascript
function setrandomimg(){ var items = ['url','url'] var item = items[math.floor(math.random()*items.length)]; document.getelementbyid(id-of-your-body/container).style.background-image='url('+item+')' }
and add onload container (example <body onload='setrandomimg()'>
)
Comments
Post a Comment