In this blog we will learn about jQuery.noConflict() or $.noConflict() method to
avoid the conflict between the jQuery library.
In the JavaScript library, we apply $ Symbol for variable names and methods.
jQuery is not an exception. Therefore we use multiple frameworks that use $ and
their application is different, it is recommended to apply the
jQuery.noConflict() or $.noConflict() method.
Why we use noConflict() Method:
If we are using two different frameworks with the same shortcut $ then one of them stops working due to conflict so to avoid the conflict between the two frameworks. we use $.noConflict() method.
Solution:
- jQuery team comes with the noConflict Method that is very useful when we use two or more different frameworks.
- In the JQuery noConflict() Method hold the $.
Syntax:
Syntax of noConflict method.
$.noConflict()
Example 1:
In this example, we will see how $.noConflict() method work:
Example2:
In this example, we will learn about how to create your own shortcut for jQuery.
Example3:
In this example, we will see how to avoid conflict when we will use two different libraries of jQuery on the same page.
Be the first to comment.