删除div后显示弹出窗口

div*_*vya 2 javascript jquery

我想首先删除div,然后显示我的弹出窗口.但在显示警报时,我能够看到div.关闭弹出窗口后,div将被删除.

$("#btnRemoveDiv").on("click",function(){$("#divRemove").remove();
alert("Removed");});
Run Code Online (Sandbox Code Playgroud)
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<div id="divRemove">Remove this div first then show the popup. Dont show this while the popup is opened!</div>
<input type="button" id="btnRemoveDiv" value="Remove">
Run Code Online (Sandbox Code Playgroud)
在此输入图像描述

@quirimmo请看这个:

qui*_*mmo 8

when它来管理它作为一个承诺,它应该工作:

$("#btnRemoveDiv").on("click",function(){
  $.when($('#divRemove').remove()).then(function() {alert('removed');});
});
Run Code Online (Sandbox Code Playgroud)
<script
  src="https://code.jquery.com/jquery-3.2.1.min.js"
  integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  crossorigin="anonymous"></script>
<div id="divRemove">Remove this div first then show the popup. Dont show this while the popup is opened!</div>
<input type="button" id="btnRemoveDiv" value="Remove">
Run Code Online (Sandbox Code Playgroud)

的jsfiddle:

https://jsfiddle.net/91x9ta3n/12/