0

我在一个 HTML 页面中有三个 div。页面看起来像这样

HTML页面:

   leftArrow(>)   div   rightArrow(<)

我需要从左到右和从右到左移动 div。使用 javascript 和 DHTMl

或 jQuery。

有可能朝那个方向移动吗?

4

2 回答 2

1

是的,这是可能的,我过去没有使用 jQuery 就完成了。

我有以下标记:

<div id="HorThumbs" style="overflow:hidden;width:500px">
  <div id="HorScroller" style="width:1000px">
    //Data to be shown
  </div>
</div>

var scrollStep=1;
var timerLeft,timerRight="";
function scrollDivLeft(id){
  clearTimeout(timerRight);
  document.getElementById(id).scrollLeft-=scrollStep;
  timerRight=setTimeout("scrollDivLeft('"+id+"')",1);
}

function scrollRight(id){
  clearTimeout(timerLeft);
  document.getElementById(id).scrollLeft+=scrollStep;
  timerLeft=setTimeout("scrollRight('"+id+"')",1);
}

然后向左右箭头添加一个 MouseOver 事件,将“HorThumbs”作为 Id 传递给 scrollDivLeft 或 scrollDivRight 函数。

于 2009-06-01T09:43:09.690 回答
0

看看jQuery 循环插件。它将向左/向右滚动并允许上一个/下一个按钮。

于 2009-06-01T10:50:17.230 回答