jquery.js与prototype.js冲突 [英] jquery.js conflicts with prototype.js

查看:68
本文介绍了jquery.js与prototype.js冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在灯箱窗口中使用prototype.js,在同一窗口中使用jquery.validate.js进行表单验证,但是两个脚本都发生冲突

I'm using prototype.js for light box window and jquery.validate.js using for form validation in same window but both the scripts are getting conflicts

我使用了noconflict函数,但仅灯箱有效的表单验证无效

i used noconflict function but light box only working form validation is not working

灯箱脚本

<script type="text/javascript" src="javascripts/prototype.js"> </script>
<script type="text/javascript" src="javascripts/effects.js"> </script>
<script type="text/javascript" src="javascripts/window.js"> </script>
<script type="text/javascript" src="javascripts/window_effects.js"> </script>
<script type="text/javascript" src="javascripts/debug.js"> </script>

验证提示

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.validate.js"></script>

推荐答案

如果调用jQuery.noConflict();,它将不会将$与jQuery关联.

If you call jQuery.noConflict(); it would not associate $ with jQuery.

然后,您只需将jquery函数用作JQuery(element).html()并将原型与$一起使用.

Then you would just use jquery functions as JQuery(element).html() and Prototype with $.

正如Nick所建议的,有一个灯箱jQuery插件,可以在此处

As Nick suggested, there's a lightbox jQuery plugin, which can be found here

如果您确实需要同时使用两者,请在 answer 提供了一些可能对您有帮助的信息.

If you really need to use both, this answer has some information that might help you.

但是最好避免使用一个库以避免麻烦.

But it might be best to stick with one library to avoid the hassle.

这篇关于jquery.js与prototype.js冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆