我有一个HTML网页放置三个div的。页面看起来像这样

HTML页:

   leftArrow(>)   div   rightArrow(<)

我需要从左至右和从右到左移动DIV。使用JavaScript和DHTML

或JQuery的。

是否有可能在该方向上移动?

没有正确的解决方案

其他提示

是的,它是可能的,我已经做到了在过去没有使用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功能。

看一看的 jQuery的周期插件。它将滚动左/右和允许上/下一个按钮。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top