Jquery noConflict() Explained

What is noConflict() method in jQuery?
This is very important to differentiate scripts when we are using many JavaScript framework in our project.As we know jQuery uses dollar symbol ($) as shortcut. There are many other popular frameworks are there as Angular JS,Knockout JS,Kendo JS,Backbone JS,Ember ,Vue etc.
Suppose i one of these frameworks is using the $ symbol as shortcut then one of the scripts either jQuery or othe framework implemented parallel may stop working. noConflict is a method to avoid such situation in script.

We can create our self defined symbol or string as shortcut for jQuery. noConflict() return a reference and we can store this reference in a variable.

Example of noConflict() and self defined shortcut:

var jq = $.noConflict();
jq(document).ready(function(){
    jq("button").click(function(){
        jq("p").text("Hi there,Conflict resolved");
    });
});

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  

Related Posts

interview-questions-answers-pdf

Interview Questions and Answers in PDF

Magento Interview Questions and Answers DOWNLOAD PDF Laravel Interview Questions and Answers DOWNLOAD PDF Angular
angular-interview-questions-answers

Angular Basic Interview Questions and Answers

What is Angular JS? Angular JS is a JavaScript framework used for developing single-page applications.It
code-igniter-interview-questions-answers

What is New In CodeIgniter 4.x?

As we all know CodeIgniter is a PHP light weight MVC framework .It provide us