This jQuery works on 3 divs - leftKey, rightKey and mentors. They are all aligned properly. The goal is that when the leftKey is clicked, mentors will cycle through a list of background colors. I defined the colors in an array; red then blue then green. I've gotten the keys to respond on click, but the switch doesn't work.
$(document).ready(function() {
var colors = [ "rgb(128, 0, 0)", "rgb(255, 0, 0)", "rgb(0, 0, 255)", "rgb(0, 128, 0)"];
//burgundy, red, blue, green
var mentors = $("#mentors");
$("#leftKey").click(function() {
if(mentors.css("background-color") == colors[0]) {
mentors.css("background-color", colors[colors.length-1]);
} else {
for(var x = 0; x < colors.length; x++) {
if( mentors.css("background-color") == colors[x]) {
mentors.css("background-color", colors[x-1]);
}
}
};
});
$("#rightKey").click(function() {
if( mentors.css("background-color") == colors[colors.length-1]){
mentors.css("background-color", colors[0]);
} else {
for(var x = 0; x < colors.length; x++) {
if( mentors.css("background-color") == colors[x] ) {
mentors.css("background-color", colors[x+1]);
return false;
}
}
};
});
switch($("#mentors").css("background-color")case colors[0]: $("#mentors").css("background-color", colors[1];ofcss()method