1
The question is as follows, as I pass the image as parameter to use it in javascript with tried in the code below?
HTML
<!doctype html>
<html lang="pt-br">
<head>
<meta charset="utf-8"></meta>
<script type="text/javascript" src="javascript.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="botao_1"class="bgbotaorank" style="background-image:url('twitter.png');" onclick="muda_imagem('botao_1','twitter.png');">
</div>
<div id="botao_2" class="bgbotaorank" onclick="muda_imagem('botao_2','twitter.png');">
</div>
<div id="botao_3" class="bgbotaorank">
</div>
<div id="botao_4" class="bgbotaorank"></div>
</body>
</html>
Javascript
function muda_imagem(id, imagem) {
document.getElementById("botao_1").style.backgroundImage = "url('red.png')";
document.getElementById("botao_2").style.backgroundImage = "url('red.png')";
document.getElementById("botao_3").style.backgroundImage = "url('red.png')";
document.getElementById("botao_4").style.backgroundImage = "url('red.png')";
document.getElementById(id).style.backgroundImage = 'url(imagem)';
}