jQuery: Javascript Library conflicts
15/02/2009Sometimes, jQuery and other libraries must be used at the same time during a webpage development. The problem starts when both libraries(like prototype) use the same annotation e.g. ‘$(document).ready’. One of the two libraries is expected not to work at the same time. It is very easy to get over this. You just have to put something like this into your code:
<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script type="text/javascript"><!--
jQuery.noConflict();
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
jQuery("div").hide();
});
// Use Prototype with $(...), etc.
$('someid').hide();
// --></script>
Instead of:
<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script type="text/javascript"><!--
$(document).ready(function(){
$("div").hide();
});
// Use Prototype with $(...), etc.
$('someid').hide();
// --></script>