I have the following code:
var numberOfSelectedOptions = new Array();
numberOfSelectedOptions[0]=0;
numberOfSelectedOptions[1]=0;
numberOfSelectedOptions[2]=0;
$("a.tagvariantoption").live("click", function(){
alert(numberOfSelectedOptions[2]);
});
The alert always says "undefined". It works perfectly when alerting outside of the live event though. Any ideas on why my array is undefined or unknown within the live event?
Heres some extra info:
var startcount = 0;
var numberOfSelectedOptions = new Array();
numberOfSelectedOptions[0]=0;
numberOfSelectedOptions[1]=0;
numberOfSelectedOptions[2]=0;
$("a.tagvariantoption").live("click", function(){
alert(startcount); //gives 0
alert(numberOfSelectedOptions[0]); //gives undefined???
)};
The HTML is working because startcount is printed correctly, but my array stays unknown within the event.