Jquery Noconflict()
jQuery - The noConflict() Method
What if you lot want to job other frameworks on your pages, piece all the same using jQuery?
jQuery as well as Other JavaScript Frameworks
As you lot already know; jQuery uses the $ sign equally a shortcut for jQuery.There are many other pop JavaScript frameworks like: Angular, Backbone, Ember, Knockout, as well as more.
What if other JavaScript frameworks equally good job the $ sign equally a shortcut?
If ii dissimilar frameworks are using the same shortcut, ane of them powerfulness cease working.
The jQuery squad convey already idea close this, as well as implemented the noConflict() method.
The jQuery noConflict() Method
The noConflict() method releases the concur on the $ shortcut identifier, as well as thus that other scripts tin job it.You tin of course of written report all the same job jQuery, exactly yesteryear writing the sum advert instead of the shortcut:
Example
$.noConflict();
jQuery(document).ready(function(){
jQuery("button").click(function(){
jQuery("p").text("jQuery is all the same working!");
});
});
Example
var jq = $.noConflict();
jq(document).ready(function(){
jq("button").click(function(){
jq("p").text("jQuery is all the same working!");
});
});
Example
$.noConflict();
jQuery(document).ready(function($){
$("button").click(function(){
$("p").text("jQuery is all the same working!");
});
});
Comments
Post a Comment