我还在学习JavaScript并需要一些帮助。我正在制作下一个和上一个按钮,导致滚动到页面上的下一个或上一个<td>
's。我正在试图将这个实现到virb站点的现有结构。 标记看起来是这样的:下一个/上一个按钮onClick滚动到下一个和上一个的
div id="next">next</div><div id="prev">prev</div>
<table>
<tr><td>code that includes img</td></tr>
<tr><td>code that includes img</td></tr>
<tr><td>code that includes img</td></tr>
<tr><td>code that includes img</td></tr>
<tr><td>code that includes img</td></tr>
</table>
这是我的工作脚本:
jQuery.easing.def = "easeInOutQuad";
$("#next").click(function(){
//$(this).animate(function(){
$('html, body').animate({
scrollLeft: $("td").next.offset().left
}, 600);
//});
});
这里是更新的小提琴http://jsfiddle.net/garretthaas/kzqVp/8/ – glh16