gpt4 book ai didi

javascript - 滚动 bootstrap 3 模态

转载 作者:行者123 更新时间:2023-11-28 07:59:04 25 4
gpt4 key购买 nike

所以我有这个模式,当您单击计算按钮时,我想自动向下滚动到图表区域。我有这个代码:

  $('#budgetCalModal').animate({
scrollTop: $("#result").offset().top
}, 1000);

但是好像不行。我正在使用 bootstrap 3。有什么线索吗?

PS:当模态明显大于窗口高度时,应该滚动。

谢谢

enter image description here

最佳答案

我不知道这是否能解决您的问题,但这里有一个 fiddle - http://jsfiddle.net/qe1w87ba/它根据模式窗口中的 anchor 标记执行您想要的操作。

 <script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {

var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('.modal').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>

关于javascript - 滚动 bootstrap 3 模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25649987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com