当前位置: 代码迷 >> Web前端 >> Jquery跟Prototype共存的方法
  详细解决方案

Jquery跟Prototype共存的方法

热度:30   发布时间:2012-10-27 10:42:26.0
Jquery和Prototype共存的方法
方式一:
Java代码
   
<html>  
<head>  
   <script src="prototype.js"></script>  
   <script src="jquery.js"></script>  
   <script>  
     jQuery.noConflict();  
       
     // Use jQuery via jQuery(...)  
     jQuery(document).ready(function(){  
       jQuery("div").hide();  
     });  
       
     // Use Prototype with $(...), etc.  
     $('someid').style.display = 'none';  
   </script>  
</head>  
<body></body>  
</html> 


<html>
<head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();
    
     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });
    
     // Use Prototype with $(...), etc.
     $('someid').style.display = 'none';
   </script>
</head>
<body></body>
</html>

方式二:
Java代码
<html>  
<head>  
   <script src="prototype.js"></script>  
   <script src="jquery.js"></script>  
   <script>  
     var $j = jQuery.noConflict();  
       
     // Use jQuery via $j(...)  
     $j(document).ready(function(){  
       $j("div").hide();  
     });  
       
     // Use Prototype with $(...), etc.  
     $('someid').style.display = 'none';  
   </script>  
</head>  
<body></body>  
</html> 

<html>
<head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     var $j = jQuery.noConflict();
    
     // Use jQuery via $j(...)
     $j(document).ready(function(){
       $j("div").hide();
     });
    
     // Use Prototype with $(...), etc.
     $('someid').style.display = 'none';
   </script>
</head>
<body></body>
</html>

方式三:
Java代码
<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').style.display = 'none';  
   </script>  
</head>  
<body></body>  
</html> 
  相关解决方案