使用链接在div内滚动div? [英] Scrolling div inside div using link?
问题描述
我想滚动到基于 id
当点击链接时div的顶部位置...
如果链接旁边点击所以div idltvmove / scroll以上图片来描述我的目的。
>
谢谢
您可以使用jQuery的 scrollTop 函数
$('#点击(函数(e){
e.preventDefault();
$('#divId')。scrollTop(0);
});
如果你想让它像一个幻灯片一样,可以用 .animate
:
$('#divId')。stop()。 animate({scrollTop:0px});
如果您想让某个div跳到顶部,您需要制定出它的yfefest,然后使用它作为scrollTop px
i want to scroll to top position of div based id
when link clicked...
if link beside click so div id "ltv" move / scroll to top..
this my picture to describe my purpose
if anyone knows how to do this, or can give me a good starting point I'd appreciate it.
Thanks
you can use jQuery's scrollTop function
$('#ltv').click(function(e) {
e.preventDefault();
$('#divId').scrollTop(0);
});
If you want this to be like a slide up to the top, you can use it with .animate
:
$('#divId').stop().animate({ scrollTop: "0px" });
if you are wanting a certain div to go to the top, you are gouing to have to work out its y offest and then use that as the scrollTop px
这篇关于使用链接在div内滚动div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!