
两个JS,网页导航栏和图片切换冲突,导航栏用Jquery 是不是因为函数名$ 冲突 怎么改?
图片切换部分JS代码:varisIE=(document.all)?true:false;var$=function(id){return"string"==typeof...
图片切换部分JS代码:
var isIE = (document.all) ? true : false;
var $ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
var Class = {
create: function() {
return function() { this.initialize.apply(this, arguments); }
}
}
var Extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
}
var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}
var Each = function(list, fun){
for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
};
var RevealTrans = Class.create();
RevealTrans.prototype = {
initialize: function(container, options) {
this._img = document.createElement("img");
this._a = document.createElement("a");
this._timer = null;//计时器
this.Index = 0;//显示索引
this._onIndex = -1;//当前索引
this.SetOptions(options);
this.Auto = !!this.options.Auto;
this.Pause = Math.abs(this.options.Pause);
this.Duration = Math.abs(this.options.Duration);
this.Transition = parseInt(this.options.Transition);
this.List = this.options.List;
this.onShow = this.options.onShow;
//初始化显示区域
this._img.style.visibility = "hidden";//第一次变换时不显示红x图
this._img.style.width = this._img.style.height = "100%"; this._img.style.border = 0;
this._img.onmouseover = Bind(this, this.Stop);
this._img.onmouseout = Bind(this, this.Start);
isIE && (this._img.style.filter = "revealTrans()");
this._a.target = "_blank";
$(container).appendChild(this._a).appendChild(this._img);
},
}; 展开
var isIE = (document.all) ? true : false;
var $ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
var Class = {
create: function() {
return function() { this.initialize.apply(this, arguments); }
}
}
var Extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
}
var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}
var Each = function(list, fun){
for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
};
var RevealTrans = Class.create();
RevealTrans.prototype = {
initialize: function(container, options) {
this._img = document.createElement("img");
this._a = document.createElement("a");
this._timer = null;//计时器
this.Index = 0;//显示索引
this._onIndex = -1;//当前索引
this.SetOptions(options);
this.Auto = !!this.options.Auto;
this.Pause = Math.abs(this.options.Pause);
this.Duration = Math.abs(this.options.Duration);
this.Transition = parseInt(this.options.Transition);
this.List = this.options.List;
this.onShow = this.options.onShow;
//初始化显示区域
this._img.style.visibility = "hidden";//第一次变换时不显示红x图
this._img.style.width = this._img.style.height = "100%"; this._img.style.border = 0;
this._img.onmouseover = Bind(this, this.Stop);
this._img.onmouseout = Bind(this, this.Start);
isIE && (this._img.style.filter = "revealTrans()");
this._a.target = "_blank";
$(container).appendChild(this._a).appendChild(this._img);
},
}; 展开
3个回答
展开全部
是定义的$冲突引起
var $ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
$改为 MContain
var MContain = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
$(container).appendChild(this._a).appendChild(this._img);
改为
MContain(container).appendChild(this._a).appendChild(this._img);
var $ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
$改为 MContain
var MContain = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
$(container).appendChild(this._a).appendChild(this._img);
改为
MContain(container).appendChild(this._a).appendChild(this._img);
追问
改了后导航栏正常了,但是图片切换还是不能实现,要不你给我邮箱 我把文件发给你 你帮我看看
追答
12179110#qq.com
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
将导航栏代码里的$都换成jQuery。或者给放到一个命名空间里。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你可以把所有的“$”换成“jQuery”试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询