What is jQuery(document) vs. $(document)

前端 未结 6 2016
灰色年华
灰色年华 2020-12-01 21:25

I don\'t get what jQuery(document) is here. I thought you always used $(document)

see here in his examples: http://sorgalla.com/projects/jcarousel/

相关标签:
6条回答
  • 2020-12-01 22:11

    jQuery(document) and $(document) both are alternative

    0 讨论(0)
  • 2020-12-01 22:18

    The $ is just a shortcut for JQuery.

    0 讨论(0)
  • 2020-12-01 22:19

    jQuery uses $(). Prototype uses $(). AFAIK Mootools uses $(). 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() is recommended over $() for use in jQuery plugins, so they keep functioning if you do disable $().

    0 讨论(0)
  • 2020-12-01 22:20

    It's like <? versus <?php: one is a shorthand version that may be vulnerable to conflicts.

    0 讨论(0)
  • 2020-12-01 22:23

    jQuery is just the long-hand way of invoking 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.

    0 讨论(0)
  • 2020-12-01 22:27

    There is no difference. $ is shorthand for jQuery. Sometimes $ is disabled as it may conflict with other Javascript libraries you are using. It is otherwise identical.

    0 讨论(0)
提交回复
热议问题