0

Here is the jQuery latest.

It is wrapped in a anonymous immediately invoked function expression ( aiife )

(function( window, undefined ) {
    // all jQuery code
})( window );

How do you access the $ sign , the alias of for jQuery that is so popular?

I thought you needed a name to access if you were going to access something?

4

3 回答 3

3

答案在以下几行中:

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

换句话说,两者都jQuery$定义为全局对象的属性。这使它们可以按原样访问 - byjQuery$. )

于 2012-08-15T21:30:38.120 回答
3

window对象足以使变量可访问。它基本上是全局对象,执行页面的范围。因此,您可以执行以下操作:

window.test = 'hello!';
alert(test);
于 2012-08-15T21:30:27.053 回答
0

不,$是 Javascript 变量的有效名称,jQueryX.js 定义了它。所以你可以使用,例如,

$(document).ready(){}

或者

$('div').hide();

ETC

于 2012-08-15T21:31:05.827 回答