当前位置: 代码迷 >> JavaScript >> jQuery与prototype.js兼容性有关问题解决方案
  详细解决方案

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

热度:38   发布时间:2012-08-28 12:37:01.0
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(){
		……
	});
});
  相关解决方案