What is jquery noConflict, why do we need it?

I saw jquery code containing jQuery.noConflict method.

I don’t know the purpose, I don’t understand why we need it.

I only understand that this is related to the jquery plugin.

+3
source share
2 answers

jQuery (and other similar structures) store the alias of the jQuery object in a variable $. It is just for easy pruning when you write code.

You could write all your code, like this jQuery('.selector');, instead of using the dollar sign if you want. Conflict-free mode allows you to use a different code (usually a different framework), which also stores something in a dollar sign variable.

+2
source

, javascript, , , jQuery, .. $ , jQuery. jQuery.noConflict.

:

jQuery ( )

Update:

, jQuery.noConflict, $ , jQuery, jQuery, $.

, jQuery, :

(function($){
 // your code....
})(jQuery);

, , $ , .

+10

Source: https://habr.com/ru/post/1754275/


All Articles