Bootstrap Javascript组件,模态框级联open解决方案

<script type="text/javascript">
    top.global={zIndex:null};
    $("body>div[data-manage]").on('show.bs.modal',function(e){
        let relatedTarget=$(e.relatedTarget);
        if(relatedTarget.attr("data-toggle")=="modal"){
            let targetName=relatedTarget.attr("data-target");
            if(targetName!=null){
                //设置z-index值
                if(top.global.zIndex==null){
                    top.global.zIndex = parseInt($(targetName).css("z-index"));
                }
                $(targetName).css("z-index",top.global.zIndex++);
                console.log("count:"+$("div.modal-backdrop").length);
            };
        };

    });

    $("body>div[data-manage]").on('shown.bs.modal',function(e) {
        let modal_backdrop_first=$("div.modal-backdrop:first");
        modal_backdrop_first.css("display","block");
        $("div.modal-backdrop").not(modal_backdrop_first).css("display","none");
    });

</script>

只需要更改Jquery的selector选择器就可以使用了

posted @ 2019-08-11 21:48  星小梦  阅读(391)  评论(0编辑  收藏  举报