我有这段代码,当它们的 ID 放在 hrefs 中时,它会滚动到特定元素(这里是演示):
$('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) {
$('html,body').animate({
scrollTop: target.offset().top - 125
}, 1000);
return false;
}
}
});
问题是,我认为它与 Bootstrap JS 组件冲突,尤其是模式。现在,打开我的模态似乎不像以前那样工作:
关联:
<a href="#myModal" role="button" class="btn btn-primary btn-large" data-toggle="modal">Sign-up for Beta!</a>
JS:
$('#myModal').modal({
keyboard: true,
show: false,
backdrop: 'static'
});
元素:
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>
谁能帮我解决这个冲突?任何建议将不胜感激。谢谢!