Created
September 22, 2016 02:04
-
-
Save lucianobarauna/d2fe2b39c524281616134cdb9f41d97f to your computer and use it in GitHub Desktop.
Snippet para imagem dinâmica
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var elP = document.querySelector('#valor'), | |
arrayNumero = ['sala', 'coziha', 'banheiro', 'casa']; | |
elP.textContent = arrayNumero[Math.floor(Math.random()*4)]; | |
// var elBox = document.querySelector('.box'), | |
// arrayImagens = ["url('img/sala.jpg')", | |
// "url('img/cozinha.jpg')", | |
// "url('img/banheiro.jpg')", | |
// "url('img/casa.jpg')"]; | |
// elBox.style.backgroundImage = arrayImagens[Math.floor(Math.random()*4)]; | |
// console.log(elBox); | |
var elBox = $('.box'), | |
arrayImagens = ["url('img/sala.jpg')", | |
"url('img/cozinha.jpg')", | |
"url('img/banheiro.jpg')", | |
"url('img/casa.jpg')"], | |
imgAmostra = arrayImagens[Math.floor(Math.random()*4)]; | |
elBox.css("backgroundImage", imgAmostra); | |
if(imgAmostra == arrayImagens[0]){ | |
elBox.css("backgroundSize", "cover"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment