Difference between jquery and $

前端 未结 8 1766
北荒
北荒 2021-01-02 14:09

I did heavy use of jquery on my php project. But on some page the $ is not working, so I have to use jquery. For example:

jQuery(\'#mycarousel\'         


        
相关标签:
8条回答
  • $ is an alias of jQuery in old version.

    In latest version if you're using this $ then that function will not execute.

    So, no need to change the entire code with jQuery...

    before that code, put:

    var $ = jQuery; 
    

    very simple...

    0 讨论(0)
  • 2021-01-02 14:20

    It's a jquery conflict. You should use a correct jquery plugin to solve this problem. use a latest Jquery plugin and remove the old one from your code.

    0 讨论(0)
  • 2021-01-02 14:21

    when .noConflict() is called, selector like $('') is no longer working to ensure compatibility with other framework such as Prototype. at that time jQuery('') is used instead.

    Reference: jQuery.noConflict()

    To better illustrate the idea, here is an example obtained from the reference link:

    <script type="text/javascript">
      $.noConflict();
      jQuery(document).ready(function($) {
        // Code that uses jQuery's $ can follow here.
      });
      // Code that uses other library's $ can follow here.
    </script>
    
    0 讨论(0)
  • 2021-01-02 14:31

    these are same except $ is ShortForm of Jquery in Jquery

    0 讨论(0)
  • 2021-01-02 14:35
    $.ajax({
        url: 'Emp.asmx/getDesignation',
        type:'post',
        contentType: 'application/json;charset=utf-8',
        dataType: 'json',
        data: "{}",
        aync: false,
    
    0 讨论(0)
  • 2021-01-02 14:36

    $ is just a variable that is used to alias jQuery and it is a varible so anything could be assigned to it.

    You can get detailed information related to it from its Documentation

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