Reputation: 583
I am trying to remove a div after a timed event using jquery.. currently the initial timer is as follows.....
$(document).ready(function () {
setTimeout(function () {
$("#loader-wrapper .loader-section, #textbit").hide("slow");
$("#logo").animate({ left: '-115px', top: '-60%' });
$("#logo-side").animate({ opacity: 9 }, 2000);
$("#loader-wrapper").remove();
}, 2000);
});
I am doing a few things here with divs outside the loader-wrapper but the div logo needs to remain on the page while the loader-wrapper needs to go after the timed event has performed all functions...
in its current form the loader-wrapper is removed (without the .hide transition happening) and also the logo div which is nested inside it... can somebody suggest/provide a workaround ?
the html looks like this ....
<div id="loader-wrapper">
<div id ="wrapper">
<div id="logo"><a href="index.html"><img src="images/mthc/logo-main.png" height="130px" width="420px"></a>
</div>
</div>
</div>
Upvotes: 1
Views: 679
Reputation: 364
try
$(document).ready(function() {
setTimeout( function () {
$("#loader-wrapper .loader-section, #textbit").hide("slow");
$("#logo").animate({left: '-115px', top:'-60%'});
$( "#logo-side" ).animate({ opacity: 9 }, 2000);
setTimeout(function(){
$("#loader-wrapper").remove();
},4000);
}, 2000 );
This will remove the #loader-wrapper after the animation is running });
Upvotes: 1
Reputation: 20626
If you are not sure about the child elements,
Use,
$("#loader-wrapper > *").unwrap();
Also, use animate()
callbacks to have the elements removed after the animation occurs.
$("#logo-side").animate({
opacity: 9
}, 2000, function () {
$("#loader-wrapper > *").unwrap();
});
Upvotes: 1
Reputation: 8961
It sounds like you just want to remove the #loader-wrapper
div?
In that case, you can use jquery's unwrap
$('#wrapper').unwrap();
Upvotes: 2
Reputation: 53991
jQuery has an unwrap
method that you can use to remove the loader-wrapper
.
$('#wrapper').unwrap();
https://api.jquery.com/unwrap/
Upvotes: 5
Reputation: 7004
You can use unwrap to remove the wrapper.
$("#wrapper").unwrap();
Upvotes: 0