如何转换它加载和卸载ajax页面而不是模态div的脚本?让我们说页面的名称是about.html。
$('#modal-about-open').on('click', function(e) {
var mod = $('#main'),
modal = $('#modal-about');
mod.animate({ opacity: 0 }, 400, function(){
$('html,body').scrollTop(0);
modal.addClass('modal-active').fadeIn(400);
});
e.preventDefault();
$('.modal-close').on('click', function(e) {
modal.removeClass('modal-active').fadeOut(400, function(){
mod.animate({ opacity: 1 }, 400);
});
e.preventDefault();
});
});
在打开时加载#modal-about div中的about.html:
$('#modal-about-open').on('click', function(e) {
var mod = $('#main'),
modal = $('#modal-about');
mod.animate({ opacity: 0 }, 400, function(){
$('html,body').scrollTop(0);
//ajax call
$.ajax({
url: "about.html",
success: function(result){
$("#modal-about").html(result); //print the received data into modal
}});
modal.addClass('modal-active').fadeIn(400);
});
e.preventDefault();
//....