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.