`

冲突解决多个Jquery包和其他前端js包命名冲突问题

阅读更多
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>冲突解决1</title>
<!-- 引入 prototype  -->
<script src="prototype-1.6.0.3.js" type="text/javascript"></script>
<!-- 引入 jQuery  -->
<script src="jquery-1.3.1.js" type="text/javascript"></script>
</head>
<body>
<p id="pp">test---prototype</p>
<p >test---jQuery</p>

<script type="text/javascript">
    jQuery.noConflict(); 			//将变量$的控制权让渡给prototype.js
    jQuery(function() {					//使用jQuery
        jQuery("p").click(function() {
            alert(jQuery(this).text());
        });
    });
    $("pp").style.display = 'none'; 	//使用prototype

</script>

</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics