同一个页面JS冲突怎么办?
window.onload;window.onload=function(){varbox=$('#slide_box'),uls=$('ul.slide_img'),o...
window.onload;
window.onload = function (){
var box = $('#slide_box'),uls = $('ul.slide_img'),order = $('#slide_order',box),lis = $('li',uls),widths = 0,runtime = 600,latency = 5000,control,num = 0,winW = $(window).width();
for (var i = 0; i < lis.length; i++) {
widths += lis.eq(i).width();
order.append('<a href="javascript:vide(0)">'+(i+1)+'</a>');
};
uls.width(widths);
box.css({left : (winW - box.width())/2});
order.find('a').removeClass('current').eq(num).addClass('current');
control = setTimeout( slide, latency );
function slide () {
var width = 0;
num = num < lis.length - 1 ? (num + 1) : 0;
var old_box_width = box.width();
var lis_now_width = lis.eq(num).width();
box.animate({width : lis_now_width,left : (winW - lis_now_width)/2},runtime);
for (var j = 0; j < num; j++) {
width += lis.eq(j).width();
};
order.find('a').removeClass('current').eq(num).addClass('current');
uls.animate({left: 0 - width}, runtime, function () {
control = setTimeout( slide, latency );
});
}
$('a',order).live({
click: function () {
uls.stop();
clearTimeout(control);
num = $(this).index() - 1;
slide();
}
});
};
第二个JS
<script>
$(function(){
window.onload = function()
{
var $li = $('#tab li');
var $ul = $('#content ul');
$li.mouseover(function(){
var $this = $(this);
var $t = $this.index();
$li.removeClass();
$this.addClass('current');
$ul.css('display','none');
$ul.eq($t).css('display','block');
})
}
});
</script> 展开
window.onload = function (){
var box = $('#slide_box'),uls = $('ul.slide_img'),order = $('#slide_order',box),lis = $('li',uls),widths = 0,runtime = 600,latency = 5000,control,num = 0,winW = $(window).width();
for (var i = 0; i < lis.length; i++) {
widths += lis.eq(i).width();
order.append('<a href="javascript:vide(0)">'+(i+1)+'</a>');
};
uls.width(widths);
box.css({left : (winW - box.width())/2});
order.find('a').removeClass('current').eq(num).addClass('current');
control = setTimeout( slide, latency );
function slide () {
var width = 0;
num = num < lis.length - 1 ? (num + 1) : 0;
var old_box_width = box.width();
var lis_now_width = lis.eq(num).width();
box.animate({width : lis_now_width,left : (winW - lis_now_width)/2},runtime);
for (var j = 0; j < num; j++) {
width += lis.eq(j).width();
};
order.find('a').removeClass('current').eq(num).addClass('current');
uls.animate({left: 0 - width}, runtime, function () {
control = setTimeout( slide, latency );
});
}
$('a',order).live({
click: function () {
uls.stop();
clearTimeout(control);
num = $(this).index() - 1;
slide();
}
});
};
第二个JS
<script>
$(function(){
window.onload = function()
{
var $li = $('#tab li');
var $ul = $('#content ul');
$li.mouseover(function(){
var $this = $(this);
var $t = $this.index();
$li.removeClass();
$this.addClass('current');
$ul.css('display','none');
$ul.eq($t).css('display','block');
})
}
});
</script> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询