I have photo gallery. Every photo is placed in small div. I wanted to make effect when i click on photo, to make this div red color and it works already. But now i want the red div color change back into white when i click on it again. It would be some kind of selection effect I tried to improve my js code myself but i am very bad in it and it doesnt work
Here is how my photos are displayed from the loop
echo '<div class="thisphotobox" id="'.$photoid.'"><img src="'.$numphotos['link'].'" alt="photo" class="photolink" style="background-color:white" onclick="clicked('.$photoid.');"></div>';
And this is my function
function clicked(photoid){
var divcolor = document.getElementById(photoid.toString()).backgroundColor;
if (divcolor = "white"){
document.getElementById(photoid.toString()).style.backgroundColor = 'red';
} else {
document.getElementById(photoid.toString()).style.backgroundColor = 'white';
}
}
It changes into red but not into white. What do i do? Please help me :D