- jQuery Examples
- Examples - Home
- Examples - Set up
- Examples - Selectors
- Examples - Attributes
- Examples - Traversing
- Examples - CSS
- Examples - DOM
- Examples - Events
- jQuery Useful Resources
- jQuery - Quick Guide
- jQuery - Useful Resources
jQuery Examples - Using Multiple Libraries
You can use multiple libraries all together without conflicting each others. For example you can use jQuery and MooTool javascript libraries together.
Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $.
Run $.noConflict() method to give control of the $ variable back to whichever library first implemented it. This helps to make sure that jQuery doesn't conflict with the $ object of other libraries.
Here is simple way of avoiding any conflict −
// Import other Library // Import jQuery Library $.noConflict(); // Code that uses other library's $ can follow here.
This technique is especially effective in conjunction with the .ready() method's ability to alias the jQuery object, as within the .ready() we can use $ if we wish without fear of conflicts later −
// Import other library // Import jQuery $.noConflict(); jQuery(document).ready(function($) { // Code that uses jQuery's $ can follow here. }); // Code that uses other library's $ can follow here.
To Continue Learning Please Login
Login with Google