Why so? Is this the difference in $ / jQuery right?
Because almost every JavaScript library defines a function called $. When you have many libraries in one document, conflicts can arise. If you are sure that jQuery is and always will be the only script defining this function, I would have nothing against using $.
jQuery defines a good solution to conflict resolution: jQuery.noConflict . Using this function, you can determine your name, as a result of which jQuery will be available, for example
var $jq = jQuery.noConflict(true);
Calling this function will restore previous values ββfor the $ and jQuery variables when they existed before jQuery initialization. I donβt remember if any other libraries tried to resolve name conflicts.
If you want to use $ instead of jQuery, you can run your code all the time in a separate private area that contains the definition of $ using the self-launch function.
(function($){ // your code goes here $("body").append("<p>Hello World!</p>"); })(jQuery); // or even jQuery.noConflict()
Rafael Feb 06 2018-10-06T00 : 06
source share