I'm having a problem with my Javascript code, I can not change the background of a div, so 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 the div it changes color, clicked again it becomes white again.
I look forward to your help.