1
I’m having a problem with my Javascript code, I can’t change the background of a div, and I set it in CSS with a class and its color is white.
function escolha(id){
if(document.getElementById(id).style.backgroundColor=="#FFFFFF"){
document.getElementById(id).style.backgroundColor="#ccf2ff";
}
else{
document.getElementById(id).style.backgroundColor=="FFFFFF"
}
}
.bc{
float:left;
width:150px;
height:200px;
box-shadow: 5px 5px 5px #888888;
background-color:#FFFFFF;
margin-left:10px;
margin-top:10px;
}
<div class="bc" id="b1" onclick="escolha(this.id)">
<img src="images/af.jpg" height="150" width="100">
<p>ABUBUBUB</p>
</div>
The command is simple: Clicked on the div it changes color, clicked again it turns white.
I sincerely hope for help.
My God, I had a third bug, I put a == instead of =, it worked dude, I had not even noticed, must be sleep, thanks for the help.
– user92257
@Ruyneto I edited, also missing one
#
and I came up with another idea.– Sergio
I understood your addition, return the cute code, thanks man, seriously, at this time help me.
– user92257