<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选择器就可以使用了