Avoid jQuery conflict with Other JavaScript library(prototype,YUI,mootools)
Posted by Raj
Avoid jQuery conflict with Other JavaScript library(prototype,YUI,mootools)
In this jQuery article, I will explain how to avoid jquery conflict with other javascript libraries.
javascript libraries such as YUI, prototype conflict with Jquery library as prototype library also uses `$` sign.To resolve this issue, jQuery has .noConflict() method.
.noConflict() method: Relinquish jQuery's control of the $ variable (override the $ function)
we can avoid prototype and jquery conflict using .noConflict() method.
Example:Avoid jQuery conflict with Other JavaScript library
<html>
<title>Avoid conflict between JQuery and prototype,YUI,mootools (Other javascript Libraries)</title>
<head>
<script src="/js/prototype.js"></script>
<script src="/js/jquery.js"></script>
<script type="text/javascript" src="../other_lib.js"></script>
<script language="javascript" type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery("#t1").show();
// Do something with jQuery
});
$('t1').show();
// Do something with prototype
</script>
</head>
</html>
You can now Avoid jQuery conflict with Other JavaScript library using the above code.
I hope,this example will help you to Avoid jQuery conflict with Other JavaScript library.
In this jQuery article, I will explain how to avoid jquery conflict with other javascript libraries.
javascript libraries such as YUI, prototype conflict with Jquery library as prototype library also uses `$` sign.To resolve this issue, jQuery has .noConflict() method.
.noConflict() method: Relinquish jQuery's control of the $ variable (override the $ function)
we can avoid prototype and jquery conflict using .noConflict() method.
Example:Avoid jQuery conflict with Other JavaScript library
<html>
<title>Avoid conflict between JQuery and prototype,YUI,mootools (Other javascript Libraries)</title>
<head>
<script src="/js/prototype.js"></script>
<script src="/js/jquery.js"></script>
<script type="text/javascript" src="../other_lib.js"></script>
<script language="javascript" type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery("#t1").show();
// Do something with jQuery
});
$('t1').show();
// Do something with prototype
</script>
</head>
</html>
You can now Avoid jQuery conflict with Other JavaScript library using the above code.
I hope,this example will help you to Avoid jQuery conflict with Other JavaScript library.
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
conflict jquery,
how to avoid conflict,
JAVASCRIPT,
JQuery,
jquery conflicts,
jquery no conflict,
jquery noconflict,
jQuery.noConflict(),
mootools jquery conflict,
prototype conflict,
prototype no conflict
.You can leave a response, or trackback from your own site.