且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

" jQuery的(...)"而不是“$(...)”

更新时间:2022-06-09 08:32:33

使用$ for jQuery是完全安全的,它是jQuery的成语,at至少在你自己控制的页面上。

It's perfectly safe to use the $ for jQuery, it's the jQuery idiom, at least on your own pages which you control.

如果你确实选择在小部件中使用jQuery,你可以用一种方式来构建它以防止它发生冲突。

If you do choose to use jQuery in widgets you can structure it in a way that prevents it from conflicts.

一般来说,jQuery绑定到$和jQuery,所以单独使用jQuery并不能保证你的安全..

In general jQuery binds to both $ and jQuery so using jQuery alone does not guarantee you safey..

如果你担心的话与jQuery冲突确实暴露了$ .noConflit();
http://api.jquery.com/jQuery.noConflict/

If you are concerned with conflict jQuery does expose the $.noConflit(); http://api.jquery.com/jQuery.noConflict/

放弃对$的控制,你可以将jQuery存储在你选择的变量中(或者使用jQuery)。

Which relinquishes the control of $ and you can store jQuery in a variable of your choice (or use jQuery).

以下是基于***页面使用$符号的库,以及 ***答案

Here are the libraries that use the $ sign based on the Wikipedia page and this *** answer:


扫描此页面时,唯一想到的是:

Scanning this page, the only ones that come to mind are:


  1. jQuery - 提供jQuery.noConflict()来释放$

  2. 原型

  3. MooTools


然而,jQuery以约90%的市场份额杀死它。

However jQuery is killing it with about 90% market share..


  1. http://www.theregister.co.uk/2012/08/14/jquery_used_by_half_of_all_websites/

  2. https://***.com/questions/176324/why-does-everyone-like-jquery-more-than-prototype-script-aculo-us-or-mootools-or

  1. http://www.theregister.co.uk/2012/08/14/jquery_used_by_half_of_all_websites/
  2. https://***.com/questions/176324/why-does-everyone-like-jquery-more-than-prototype-script-aculo-us-or-mootools-or