Declaring Jquery object as variable?
I am new to Jquery and javascript.
While I was writing a javascript code, I found myself using a particular
jquery object often, so I declared a variable for it. For example,
$(document).ready(function() {
var object_list = $("#object_list");
/*Do something with the variable*/
alert(object_list);
object_list.hide();
});
However, this doesn't seem to work ("alert(object_list)" gives me a null
value).
Is declaring a variable like this wrong in jquery???
If so, then what is the right way so that I can refer to commonly used
Jquery object??\
Thanks!
No comments:
Post a Comment