What is the difference between $ and jQuery

后端 未结 6 1542
自闭症患者
自闭症患者 2020-12-02 01:31

When I try to use $(\"#div_id\") in $(document).ready it returns NULL, but when I use jQuery(\"#div_id\") it returns the actual object

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 02:03

    $ is also used in Prototype.js, which is a javascript framework like jQuery. It could be the case that your project also includes references to this framework.

    For more info on how the prototype dollar works, go here.

    You can make the two work together with the noConflict statement, as stated in the other answers. We're doing this in one of our projects, which uses the $(element) for legacy prototype code, and jQuery(element) for new jQuery code.

提交回复
热议问题