bootstrap模态框不支持多模态框,即不支持弹出了一个模态框之后,再弹出第二个模态框,只支持弹出一个模态框
想要弹出第二个模态框,在js中加入如下代码
$(document).on('show.bs.modal', '.modal', function(event) {undefined
$(this).appendTo($('body'));
}).on('shown.bs.modal', '.modal.in', function(event) {undefined
setModalsAndBackdropsOrder();
}).on('hidden.bs.modal', '.modal', function(event) {undefined
setModalsAndBackdropsOrder();
});
function setModalsAndBackdropsOrder() {
var modalZIndex = 1040;
$('.modal.in').each(function(index) {undefined
var $modal = $(this);
modalZIndex++;
$modal.css('zIndex', modalZIndex);
$modal.next('.modal-backdrop.in').addClass('hidden').css('zIndex', modalZIndex - 1);
});
$('.modal.in:visible:last').focus().next('.modal-backdrop.in').removeClass('hidden');
}
具体使用如下: