繁体   English   中英

jquery.min.js冲突

[英]jquery.min.js Conflicts

当我添加以下脚本时,它会影响项目的其他功能(Spring应用程序)

  <script type="text/javascript" src="${ctx}/js/jquery-1.3.2.min.js"></script>

我的密码

    <script type="text/javascript" src="${ctx}/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="${ctx}/js/easy.notification.js"></script>
    <script type="text/javascript">

    $.noConflict();

    $(function() {
            $("input[type='text']").blur(function() {

                if (this.value === '') {
                    $.easyNotificationEmpty('Warning : You left this field empty !');
                } else {
                    $.easyNotification('Saved Successfully !');
                }
            })
        });
</script>

我怀疑是因为jquery-1.3.2.min.js的冲突

我已经尝试过$.noConflict(); ,但未获得理想的结果。

请帮助我解决此问题,谢谢。

尝试这个,

jQuery(function($) {
    $("input[type='text']").blur(function() {

        if (this.value === '') {
            $.easyNotificationEmpty('Warning : You left this field empty !');
        } else {
            $.easyNotification('Saved Successfully !');
        }
    })
});

使用$ .noConflict(); 在您添加如下所示的新jquery插件之前,

//your old plugin here

<script type="text/javascript">

$.noConflict();

</script>

// new plugin here 

//new script here

尝试在将导致其他脚本中断的脚本别名上实现jQuery.noConflict

var someAlias = $.noConflict();

并在导致问题的脚本上使用someAlias而不是$

您可以测试一下,看看是否有任何区别:

(function ($) {
    $(function() {
            $("input[type='text']").blur(function() {

                if (this.value === '') {
                    $.easyNotificationEmpty('Warning : You left this field empty !');
                } else {
                    $.easyNotification('Saved Successfully !');
                }
            })
        });
})(jQuery.noConflict(true))

例如:

http://jsfiddle.net/6zXXJ/

我使用TRUE,...这项工作!:

//your old plugin here


<script type="text/javascript">

$.noConflict(true);

</script>

// new plugin here 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM