Javascript & Jquery defining a global variable?
I am trying to define a global jquery object variable so that I can access
it from different functions.
This is what I am doing:
var object_list = $("#object__list");
var list_length = object_list.find("li").length;
$(document).on('keydown', '#object_list', function(event) {
//both of these don't work
alert(object_list);
alert(list_length);
});
Well,, for some reason this is not working (the first alert gives me NULL
and the second gives me 0, which is not).
Why aren't my global variables working..??
Thanks!!
No comments:
Post a Comment