首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Jquery跟Prototype共存的方法

2012-10-27 
Jquery和Prototype共存的方法方式一: Java代码htmlheadscript srcprototype.js/scriptscript

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> 

热点排行