[英]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))
例如:
我使用TRUE,...這項工作!:
//your old plugin here
<script type="text/javascript">
$.noConflict(true);
</script>
// new plugin here
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.