【发布时间】:2016-12-28 06:35:02
【问题描述】:
我在 modal 中有一个链接,我想在点击后将用户带到特定位置。目前,这是第一次工作,但是当使用模态的“关闭”按钮(不是特定链接)时对同一模态的任何后续使用,它也会将我发送到我的链接(不是预期的行为)。
这是一个 js fiddle,它显示了 Bootstrap 模式中链接的奇怪行为。 https://jsfiddle.net/x9kr2wwm/5/
我的尝试是修改此处找到的一个非常相似的问题/答案(但不是重复的):CSS Bootstrap close modal and go to link
HTML:
See the <a href="#getstarted" id="gotoLink" data-dismiss="modal">"Get Started"</a> section for more
Javascipt:
jQuery(function($) {
$("a#gotoLink").click(function(){
$('#portfolioModal1').on('hidden.bs.modal', function (e) {
$('html, body').animate({
scrollTop: $("#getstarted").offset().top
}, 2000);
})
});
});
【问题讨论】:
标签: javascript jquery css twitter-bootstrap bootstrap-modal