非原创,很久以前一篇大佬的日记了,忘了出处

  $(document).on('show.bs.modal', '.modal', function(event) {
        $(this).appendTo($('body'));
    }).on('shown.bs.modal', '.modal.in', function(event) {
        setModalsAndBackdropsOrder();
    }).on('hidden.bs.modal', '.modal', function(event) {
        setModalsAndBackdropsOrder();
    });


    function setModalsAndBackdropsOrder() {  
        var modalZIndex = 1040;
        $('.modal.in').each(function(index) {
            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');
    }

相关文章:

  • 2022-02-11
  • 2021-12-15
  • 2022-12-23
  • 2021-12-11
  • 2021-04-06
  • 2021-12-06
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2022-01-13
  • 2021-10-25
  • 2021-11-06
  • 2022-12-23
  • 2022-02-10
  • 2021-06-26
相关资源
相似解决方案