简体   繁体   English

什么是jQuery(文档)与$(文档)

[英]What is jQuery(document) vs. $(document)

I don't get what jQuery(document) is here. 我不知道jQuery(文档)在这里。 I thought you always used $(document) 我以为你总是用$(文件)

see here in his examples: http://sorgalla.com/projects/jcarousel/ 请参阅他的示例: http//sorgalla.com/projects/jcarousel/

There is no difference. 没有区别。 $ is shorthand for jQuery. $是jQuery的简写。 Sometimes $ is disabled as it may conflict with other Javascript libraries you are using. 有时$被禁用,因为它可能与您正在使用的其他Javascript库冲突。 It is otherwise identical. 它是完全相同的。

jQuery uses $(). jQuery使用$()。 Prototype uses $(). Prototype使用$()。 AFAIK Mootools uses $(). AFAIK Mootools使用$()。 If that was the end of it, it would be impossible to use any combination of the three. 如果那是它的结束,就不可能使用三者的任何组合。 So responsible frameworks provide a way to disable $() to avoid conflicts and use something else instead. 因此,负责任的框架提供了一种禁用$()的方法来避免冲突并使用其他东西。 In jQuery's case, that's jQuery(). 在jQuery的情况下,那是jQuery()。

jQuery() is recommended over $() for use in jQuery plugins, so they keep functioning if you do disable $(). jQuery()建议使用$()用于jQuery插件,因此如果禁用$(),它们将继续运行。

It's like <? 就像<? versus <?php : one is a shorthand version that may be vulnerable to conflicts. <?php :one是速记版本,可能容易受到冲突的影响。

$只是JQuery的捷径。

jQuery is just the long-hand way of invoking jQuery. jQuery只是调用jQuery的长手段。 You might want to do this if you are using it in noConflict mode or internally in a plugin to make sure you are using jQuery's $ function instead of another framework's. 如果您在noConflict模式下使用它或在插件内部使用它来确保使用jQuery的$函数而不是其他框架,则可能需要这样做。

jQuery(文档)和$(文档)都是替代方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM