Skip to content Skip to sidebar Skip to footer

Jquery Module Pattern Not Named | How Is '$' Accessible?

Here is the jQuery latest. It is wrapped in a anonymous immediately invoked function expression ( aiife ) (function( window, undefined ) { // all jQuery code })( window ); How

Solution 1:

window object is enough to make a variable accessible. It's basically global object, the scope of executing page. For that reason, you are able to do something like this:

window.test = 'hello!';
alert(test);

Solution 2:

The answer is in these lines:

// Expose jQuery to the global objectwindow.jQuery = window.$ = jQuery;

In other words, both jQuery and $ are defined as properties of global object. Which make them accessible as they are - by jQuery and $. )

Solution 3:

Nah, $ is a valid name for a Javascript variable, and jQueryX.js defines it. So you can just use, for example,

$(document).ready(){}

or

$('div').hide();

etc

Post a Comment for "Jquery Module Pattern Not Named | How Is '$' Accessible?"