I have following div in my page with some css. with this I have few div on top and below it.
HTML:
<div id="sentdiv"></div>
CSS:
#sentdiv{
margin-left: 13rem;
margin-right: 20rem;
width: 800px;
height: 600px;
padding: 50px;
}
Then I have a ajax call where in I am loading some html page like below.
JS:
$.post('/logme', function(resp) {
$("#sentdiv").load("success.html");
});
here I want to unload the success.html after 5 sec and keep the div with its CSS.
I have tried following
$("#sentdiv").delay(5000).replaceWith("<p>");
$("#sentdiv").delay(5000).fadeOut();
but It is moving the elements below it. I want to keep div and just remove the contents of div.
use the jquery method .empty()
$("#sentdiv").empty();
setTimeout(function() { $("#sentdiv").empty(); }, 5000)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="sentdiv"> <span>this will be removed in five seconds...</span> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.