I am trying to add values to a simple array, but I can't get the values pushed into the array.
So far so good, this is the code I have:
codeList = [];
jQuery('a').live(
'click',
function()
{
var code = jQuery(this).attr('id');
if( !jQuery.inArray( code, codeList ) ) {
codeList.push( code );
// some specific operation in the application
}
}
);
The above code doesn't work! But if I manually pass the value:
codeList = [];
jQuery('a').live(
'click',
function()
{
var code = '123456-001'; // CHANGES HERE
if( !jQuery.inArray( code, codeList ) ) {
codeList.push( code );
// some specific operation in the application
}
}
);
It works!
I can't figure out what's going on here, because if I do other tests manually it also work!