日期:2014-05-16  浏览次数:20301 次

jQuery与prototype.js兼容性问题解决方案

示例代码:

1、在页面中先引入jquery.js,然后通过“jQuery=$;”语句,使用“jQuery”代替$,最后再引入prototype.js。

<script type="text/javascript" src="<html:rewrite page='/js/jquery/jquery.js'/>"></script>
<script type="text/javascript">
	jQuery=$;
</script>
<script src="<html:rewrite page='/js/prototype.js'/>" type="text/javascript"></script>

2、使用jquery的js代码中,使用"jQuery"代替"$"。

?

jQuery(document).ready(function() {
	jQuery("[type=text][name^=start_]").keypress(function(){
		……
	});
});