Jcarousel和一个新添加的jQuery脚本冲突 [英] Jcarousel and a jquery new added script conflict
本文介绍了Jcarousel和一个新添加的jQuery脚本冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码与另一个jquery代码冲突.我已经使用
jQuery.noConflict();
jQuery(function ($) {
// jQuery code in here
});
但发现jcarousel触发了另一个冲突,这样做不能解决该问题,任何建议将不胜感激.
Jousousel代码
<script type="text/javascript" src="{$smarty.const._URL}/js/jquery.jcarousel.pack.js"></script>
{literal}
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
size: {/literal}{$total_playingnow}{literal}
});
});
</script>
引发冲突的新代码(facebook像likebox一样弹出):
<script type="text/javascript"/>
jQuery.noConflict();
jQuery(function ($) {
//<![CDATA[
jQuery.cookie = function (key, value, options) {
// key and at least value given, set cookie...
if (arguments.length > 1 && String(value) !== "[object Object]") {
options = jQuery.extend({}, options);
if (value === null || value === undefined) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = String(value);
return (document.cookie = [
encodeURIComponent(key), '=',
options.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || {};
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
//]]>
jQuery(document).ready(function($){
if($.cookie('popup_user_login') != 'yes'){
$('#fanback').delay('3000').fadeIn('medium');
$('#fanclose, #fan-exit').click(function(){
$('#fanback').stop().fadeOut('medium');
});
}
});
});
推荐答案
jQuery(function ($) {
// jQuery code in here
});
可以更改为
(function($){
//code here
})(jQuery)
应该解决哪些冲突问题.
Which should solve conflict issues.
这篇关于Jcarousel和一个新添加的jQuery脚本冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文