我想首先删除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请看这个:
用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/