I've been experimenting with a script that changes the CSS background color on click, but I'm having trouble adding a third color option. Can anyone provide guidance on how to make the third color work?
Check out my jsfiddle here:
https://jsfiddle.net/pkrWV/70/
var bodyObj, className, index;
bodyObj = document.getElementById('body');
index = 1;
className = [
'imageOne',
'imageTwo',
'imageThree',
];
function updateIndex(){
if(index === 0){
index = 1;
}else{
index = 0;
}
}
bodyObj.onclick = function(e){
e.currentTarget.className = className[index];
updateIndex();
}
Thank you,
James