Azharkamar.com

Solving jQuery Conflicts with other JavaScript Libraries

Tutorials
3 Nov 2010
1 comment

I was developing a page that for some reason had to use 3 different JavaScript libraries (jQuery, MooTools and Highslide) and got into so much problems. Largely because the different libraries were conflicting with each other.

So I found this thing that helped me: http://api.jquery.com/jQuery.noConflict

I just added the ‘$.noConflict();’ method and changed the ‘(function($ {‘ sign to ‘jQuery(document).ready(function($) {‘.

It solved all the conflicts for me. ;)

How to Add the noConflict() Script for jQuery

<script type="text/javascript" src="other_lib.js">
<script type="text/javascript" src="jquery.js">
<script type="text/javascript">
  $.noConflict();
  jQuery(document).ready(function($) {
    // Code that uses jQuery's $ can follow here.
  });
  // Code that uses other library's $ can follow here.
</script>

Author - Azhar Kamar
1 Lonely Comment...
  1. [...] This post was mentioned on Twitter by Javascript News, Azhar Kamar. Azhar Kamar said: Solving jQuery Conflicts with other JavaScript Libraries http://bit.ly/9JCY4X [...]

Write a Comment! NOW! :)