【发布时间】:2015-04-21 06:43:00
【问题描述】:
以下代码在页面加载时有效。但是,当我单击应该打开模式窗口的按钮时,出现以下错误:
未捕获的类型错误:无法读取未定义的属性“顶部”
我该如何解决这个错误?
if ($(window).width() > 992) {
(function($) {
"use strict";
$(".page-scroll a[href^='#'], #intro a").on('click', function(e) {
e.preventDefault();
var hash = this.hash;
$('html, body').stop().animate({
scrollTop: $(hash).offset().top - 100}, 2000, 'easeOutExpo');
});
})(jQuery);
$('body').scrollspy({
target: '.navbar',
offset: 110
});
// alert("large");
}
else {
(function($) {
"use strict";
$(".page-scroll a[href^='#'], #intro a").on('click', function(e) {
e.preventDefault();
var hash = this.hash;
$('html, body').stop().animate({
scrollTop: $(hash).offset().top - 50}, 2000, 'easeOutExpo');
});
})(jQuery);
$('body').scrollspy({
target: '.navbar',
offset: 70
});
// alert("small");
}
//modal popup function
function popup_modal(item){
var link = $(item).attr('id');
$('#bootstrap_modal').load('/'+link+'');
$('#bootstrap_modal').modal('show');
$("#bootstrap_modal").on("show", function () {
$("body").addClass("modal-open");
}).on("hidden", function () {
$("body").removeClass("modal-open")
});
}
//Modal pop up
$('.mmodal').on('click', function(){
popup_modal(this);
});
【问题讨论】:
-
能看到 html 也很高兴,它应该与 $(hash).offset().top - 50}, 2000, 'easeOutExpo');
标签: javascript jquery bootstrap-modal