What is the difference between $ and $$?

前端 未结 7 1056
执笔经年
执笔经年 2020-12-15 09:19

I have been going through some jQuery functionality.

Can any one please give me some idea of what the difference is between the use of $ and $$

7条回答
  •  一向
    一向 (楼主)
    2020-12-15 09:45

    On jQuery documentation there is no $$ statement. jQuery has a default selector with $ character. Maybe this scripts uses another javascript lib and has some conflicts with jQuery. In this case, you can use jquery.NoConflict to avoid this kind of problem, and set another jquery selector.

    Something like:

    var s = jQuery.noConflict();
    
    // something with new jQuery selector
    s("div p").hide();
    
    // something with another library using $()
    $("content").style.display = 'none';
    

    If your code has somethig like to avoid conflicts: var $$ = jquery.noConfict();, you can use $$ as a jquery selector: $$("#element").method();

    See more on the documentation: http://api.jquery.com/jQuery.noConflict/

提交回复
热议问题