jQuery and other libraries, and the usage of '$'

前端 未结 6 764
孤独总比滥情好
孤独总比滥情好 2021-01-07 03:37

I have a quick, beginners-type-question. If I were to use jQuery and some other framework, would the following statement be problematic:

jQuery(document).rea         


        
6条回答
  •  萌比男神i
    2021-01-07 03:46

    You can wrap you jQuery code part into function like this:

    function($) {
        // jQuery code here
    }(jQuery);
    
    // use $ here to access other JS library
    

    and you will be able to use $ inside the function (this is self-executing function that maps $ to jQuery.

提交回复
热议问题