源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

通过JQuery将DIV的滚动条滚动到指定的位置方便自动定位

  • 时间:2021-03-18 11:51 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:通过JQuery将DIV的滚动条滚动到指定的位置方便自动定位
这里有一个方法可以将DIV的滚动条滚动到其子元素所在的位置,方便自动定位。
[u]复制代码[/u] 代码如下:
var container = $('div'), scrollTo = $('#row_8'); container.scrollTop( scrollTo.offset().top - container.offset().top + container.scrollTop() ); // Or you can animate the scrolling: container.animate({ scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() });​
不需要任何JQuery插件即可完成所需的效果,非常好用!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部