jQuery-noConflict():
In order to resolve the conflict between Jquery & any other
JavaScript framework that also use the '$' sign as a shortcut the jQuery team implemented a
method called the noConflict() method.
What this method does is that,it releases the hold on the '$'
shortcut identifier. But we can still use jQuery keyword for writing our query instead of the
'$' sign.
Example:
$.noConflict();
jQuery(document).ready(function(){
jQuery("button").click(function(){
jQuery("p").text("jQuery is still working!");
});
});
We can also create our custom keyword instead of jQuery keyword,
as noConflict() returns the reference of jQuery which we can store in any object.
Example:
var jq = $.noConflict();
jq(document).ready(function(){
jq("button").click(function(){
jq("p").text("jQuery is still working!");
});
});
0 Comment(s)