Simple jQuery syntax help, don't know where I've gone wrong
- by Jascination
I'm having trouble with a jQuery code at the moment, I know WHERE the problem lies, but I don't know what the problem is exactly. Probably very basic, but I'm new to this.
You can see a (non)working fiddle here: http://www.jsfiddle.net/CvZeQ/
Basically I want to set different .click function based on whatever is selected (I have 5 image maps, each with a different #mapname, and want each to pertain to a different variable (answer1, answer2, answer3...) so as to store the selected 'answer' for each map.)
Here is the code I'm using for one of the maps:
$(window).load(function(){
//Get cookies when page loaded
var useranswers=$.cookie('survery');
useranswers= JSON.parse (useranswers);
// do something with previous answers
//#shape functions
$('#shape area').hover(
function(e){
$('#'+ this.alt).addClass('hover');
},
function(e){
$('#'+ this.alt).removeClass('hover');
}
).click(
function(e){
$('img.selected-region').removeClass('selected-region');
},
function(e){
$('#'+ this.alt).addClass('selected-region');
},
function(e){
var answer1 = $(this).attr("class");
});
});
I know the problem lies somewhere with the .click function, but I'm not entirely sure what I've done wrong. Any help would be greatly appreciated.