求高手解释一段js代码,作用是背景横向滚动
var scrollSpeed = 70;
var step = 1;
var current = 0;
var imageWidth = 2247;
var headerWidth = 800;
var restartPosition = -(imageWidth - headerWidth);function scrollBg(){current -= step;if (current == restartPosition){current = 0;}$('body').css("background-position",current+"px 0");}
var init = setInterval("scrollBg()", scrollSpeed);
答案:jquery?好像scrollBg()不用双引号吧,var init = setInterval("scrollBg()", scrollSpeed);也可以改成 var init = setInterval(function(){scrollBg();}, scrollSpeed);
上一个:js弹出对话框
下一个:JS问题,提示缺少对象