Hello mans!
I have six photos with name cin[1-6].gif
I have a one div with class cinema
I want to change background-image of div when I reload page.
I connect jQuery in Head
<script type="text/javascript" src="${resourcesFolderName}/jquery-2.2.1.js"></script>
Then I write a random function in Head of HTML and I try to change my backgound-image. I get this code in header:
<script type="text/javascript" src="${resourcesFolderName}/jquery-2.2.1.js"></script>
<script>
function rand(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
$(".cinema").css ({
"background":"url(${resourcesFolderName}/cin"+rand(1,7)+".gif) no-repeat !important",
"background-size":"cover"
})
</script>
Why my code is doesn’t work?