jquery与另一个js冲突
在我的网站上,我使用 TafelTree (一种创建可折叠的 JavaScript树形菜单)。最近我使用 jQuery Coundown 制作了一个小部件。
My problem is that as long as my jQuery Countdown widget is in the page, the tree menu is no longer working (it doesn't display anything)jQuery 倒计时函数的调用是:
$(function () {
var theDay = new Date();
theDay = new Date(2011, 9, 19, 20, 0, 0);
$('#evo_defaultCountdown').countdown({until: theDay, format: 'HMS'});
});
TafelTree 脚本的调用是:
function TafelTreeInit () {
var struct = [{"id" : "item_280",
"txt" : '<a class="category-link">Back to School</a>',
"url" : "/back-to-school.html", "canhavechildren" : true,
"items" : [{
"id" : "item_280_277",
"txt" : '<a href="back-to-school/notebook-acer.html">notebook Acer</a>',
"canhavechildren" : false},{
"id" : "item_280_278",
"txt" : '<a href="back-to-school/desktop-monitor-acer.html">Desktop + monitor Acer </a>',
"canhavechildren" : false},{
"id" : "item_280_266",
"txt" : '<a href="back-to-school/pc-desktop-1.html">PC Desktop</a>',
"canhavechildren" : false},{
"id" : "item_280_267",
"txt" : '<a href="back-to-school/monitor.html">monitor</a>',
"canhavechildren" : false},{
"id" : "item_280_268",
"txt" : '<a href="back-to-school/laptop-mini-laptop.html">Laptop / Mini-laptop</a>',
"canhavechildren" : false},{
]}];
]}];
function funcOpen (item, response) {
var selected = document.getElementById(item.idObj);
var selectedParent = selected.parentNode;
if(response == true) {
selected.className = selected.className+' ' + selected.className + '_open';
selectedParent.className = selectedParent.className+' ' + selectedParent.className + '_open';
} else {
selected.className = 'tafelTreecontent';
selectedParent.className = 'tafelTreecanvas';
}
return true;
}
tree = new TafelTree('menuHolder', struct, {
'generate' : true,
'imgBase' : SKIN_URL+'images/plugins/tree/',
//'defaultImg' : 'page.gif',
//'defaultImgOpen' : 'folderopen.gif',
//'defaultImgClose' : 'folder.gif',
'onLoad' : function(){},
'onOpen' : funcOpen
});
if(tree.openAll == true || tree.openAll == 'open'){
document.getElementById('nav_collapse').style.display = "block";
document.getElementById('nav_expand').style.display = "none";
} else {
document.getElementById('nav_collapse').style.display = "none";
document.getElementById('nav_expand').style.display = "block";
}
}
知道是什么导致了这种冲突吗?我该如何修复它?
On my website I'm using TafelTree (a javascript that creates a collapsible tree menu). Recently I've made a widget using jQuery Coundown.
My problem is that as long as my jQuery Countdown widget is in the page, the tree menu is no longer working (it doesn't display anything)
The call of the jQuery countdown function is:
$(function () {
var theDay = new Date();
theDay = new Date(2011, 9, 19, 20, 0, 0);
$('#evo_defaultCountdown').countdown({until: theDay, format: 'HMS'});
});
The call of the TafelTree script is:
function TafelTreeInit () {
var struct = [{"id" : "item_280",
"txt" : '<a class="category-link">Back to School</a>',
"url" : "/back-to-school.html", "canhavechildren" : true,
"items" : [{
"id" : "item_280_277",
"txt" : '<a href="back-to-school/notebook-acer.html">notebook Acer</a>',
"canhavechildren" : false},{
"id" : "item_280_278",
"txt" : '<a href="back-to-school/desktop-monitor-acer.html">Desktop + monitor Acer </a>',
"canhavechildren" : false},{
"id" : "item_280_266",
"txt" : '<a href="back-to-school/pc-desktop-1.html">PC Desktop</a>',
"canhavechildren" : false},{
"id" : "item_280_267",
"txt" : '<a href="back-to-school/monitor.html">monitor</a>',
"canhavechildren" : false},{
"id" : "item_280_268",
"txt" : '<a href="back-to-school/laptop-mini-laptop.html">Laptop / Mini-laptop</a>',
"canhavechildren" : false},{
]}];
]}];
function funcOpen (item, response) {
var selected = document.getElementById(item.idObj);
var selectedParent = selected.parentNode;
if(response == true) {
selected.className = selected.className+' ' + selected.className + '_open';
selectedParent.className = selectedParent.className+' ' + selectedParent.className + '_open';
} else {
selected.className = 'tafelTreecontent';
selectedParent.className = 'tafelTreecanvas';
}
return true;
}
tree = new TafelTree('menuHolder', struct, {
'generate' : true,
'imgBase' : SKIN_URL+'images/plugins/tree/',
//'defaultImg' : 'page.gif',
//'defaultImgOpen' : 'folderopen.gif',
//'defaultImgClose' : 'folder.gif',
'onLoad' : function(){},
'onOpen' : funcOpen
});
if(tree.openAll == true || tree.openAll == 'open'){
document.getElementById('nav_collapse').style.display = "block";
document.getElementById('nav_expand').style.display = "none";
} else {
document.getElementById('nav_collapse').style.display = "none";
document.getElementById('nav_expand').style.display = "block";
}
}
Any idea what causes this conflict? How can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用:
http://api.jquery.com/jQuery.noConflict/
在您的情况下 :
use this:
http://api.jquery.com/jQuery.noConflict/
in your case: