jQuery with other libraries

Learn how to use jQuery with other libraries.

jQuery with other libraries

jQuery jquery with other Libraries

    

There are many JavaScript libraries to help the developer to develop web applications. These libraries are designed to solve a particular problem efficiently. There may be some requirement of using these different libraries with jQuery. So, you may find incompatibility using these libraries with jQuery. In this section we are discussing the ways to use jQuery with other libraries. This issue comes as other libraries also uses $ to access the function of variable name. In this example you will see how to use $ to access both jQuery and other libraries functions and variables.

Using jQuery with other Libraries:

Let's see how we can use jQuery with other libraries.

In your application if there is requirement of including other libraries such as  prototype.js, YUI or mootools with jQuery, you can use the .noConflict() method of jQuery.

In jQuery $ is an alias for jQuery, so you can use jQuery() for accessing the jQuery methods. The following code example shows how you can use other libraries with jQuery:

<html>
<head><title>jQuery Example</title>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script>
   jQuery.noConflict(); //For using other libraries
  // Use jQuery using function jQuery(...)
  jQuery(document).ready(function(){
   //write your code here
   });
  // Use Prototype with $(...), etc.
   $('messagebox').hide();
</script>

</head>
<body><div id="messagebox"></div></body>
</html>
 

In this we have studied how to use jQuery with other libraries.

Learn from experts! Attend jQuery Training classes.