Avoid jQuery conflict with Other JavaScript library(prototype,YUI,mootools) | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

Avoid jQuery conflict with Other JavaScript library(prototype,YUI,mootools)

Thursday

Avoid jquery conflict with other javascript libraries:
                  In this jQuery article, I will explain how to avoid jquery conflict with other javascript libraries.


javascript libraries such as YUI, prototype conflict with Jquery library as prototype library also uses `$` sign.To resolve this issue, jQuery has .noConflict() method.

.noConflict() method: Relinquish jQuery's control of the $ variable (override the $ function)
we can avoid prototype and jquery conflict using .noConflict() method.


Code:

<html>  
<title>Avoid conflict between JQuery and prototype,YUI,mootools (Other javascript Libraries)</title>
<head>  
    <script src="/js/prototype.js"></script>  
    <script src="/js/jquery.js"></script>  
<script type="text/javascript" src="../other_lib.js"></script>
<script language="javascript" type="text/javascript">  
    jQuery.noConflict();  
    jQuery(document).ready(function(){  
     jQuery("#t1").show();  
 // Do something with jQuery
   });  
     $('t1').show();  
  // Do something with prototype
 </script>  
 </head>  
 </html> 

0 comments:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets