Im confused and my head is sore, please help.
I am trying to send a variable to fancybox.js when an element has a class 'selected'. This works:
var showMe = true;
This also works:
if(a){
var showMe = true;
}
This results in an alert saying "class is selected":
if($('#shuffle').hasClass('selected')){
alert("class is selected");
}
Ive also checked in Firebug and the class is selected.
The problem is when I do this it doesn't work:
if($('#shuffle').hasClass('selected')){
var showMe = true;
}
showMe is not set to true.
I know it must be simple, thanks in advance for any help.
EDIT Here is what worked: For some reason, the class changing to selected didn't set the showMe = true. I added an .click function to the button instead and it did work. Not sure why, but if you know where I should be reading into this then please past the link in here.
$(function() {
$("#shuffle").click(function(){
showMe = true;
console.log( showMe);
});
});
Thanks for everyone that responded, Im guessing the reason your answers didn't work was something to do with the way i asked the question. Cheers