I'm attempting to create a smooth slide effect for a div element before it disappears. Below is the code I am currently using:
function slideLeft(element) {
$("#" + element).animate({
left: "510"
}, {
duration: 750
});
document.getElementById(element).style.display = "none";
}
When I remove the last line of code, the div smoothly slides to the left over 750ms. However, adding the line causes the div to simply vanish.
I tried inserting the following before the last line:
wait(750);
The 'wait' function was defined as:
function wait(ms)
{
var d = new Date();
var d2 = null;
do {
d2 = new Date();
} while(d2-d < ms);
}
Unfortunately, this resulted in the div lingering for 750ms before disappearing abruptly. My goal is for the div with the ID of 'element' to gracefully slide and then disappear with display:none. Any suggestions or ideas on how to achieve this? Thank you.