Change Class of Object on Click (CSS + Javascript)

Posted:
in Genius Bar edited January 2014
So, i am trying to make a link that's class will change when someone clicks on it. I do not know Javascript, but I do know CSS, and so far I have this line of code:



Code:


<a href="#" onclick="repalceImage(thephoto);

return false;" class="front" id="thephoto"> <span>this is where the photo goes</span></a>







with this script, and the results are none:



Code:




function replaceImage(imgID) {



var foto = document.getElementById(imgID);



if ( foto.className == "front"

{



foto.className = "back";

}

else if ( foto.className == "back" {



foto.className = "front";

}

}

return foto;











Could someone give me some help, please?
Sign In or Register to comment.