Gabriel Gabriel - 2 years ago 76
Javascript Question

Storing jQuery objects using Object Literal pattern

Is it possible to store jQuery objects inside Object Literal pattern? In my case inside


var myApp = {
config: {
disabledElem: $('.disable')

init: function () {

$(function () {

Answer Source

Yes, you can absolutely store a reference as a value in an object literal.

Perhaps some of your confusion is how you are accessing this value in your init function.

Try something like this instead:

init: function () {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download