Using JQuery with Other Libraries

0

Posted on : 19-11-2008 | By : Stefan | In : Javascript

I’ve just learend something very cool today. How to use JQuery with other libraries, in my case prototype.js.

The issue is where other libraries are using $ as the same shortcut, for example JQuery uses “$” as a shortcut for “JQuery”.

Here’s the workaround:

 <html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();

     // Put all your code in your document ready area
     jQuery(document).ready(function($){
       // Do jQuery stuff using $
       $("div").hide();
     });

     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>
 </html>

For a full demo and explanation see: http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Post a comment