With a div like this:
<div id='im1' class='information_message error'>Error message here <a href='javascript:hide('im1')'>Hide</a></div>
And the following dojo/javascript code:
function hide(id){ id.innerHTML = ''; dojo.animateProperty({ node: id, duration: 500, properties: { height: {end: 0} }, onEnd: function(){ id.orphan(); } }).play(); }
I’m trying to do the following:
- Animate the resize of the div’s height to 0
- Delete the element from DOM afterwards
But currently the text doesn’t disappear, the animation animates only half-way and the div doesn’t get deleted upon animation complete. What’s the correct javascript code to accomplish my goals?
SebaGR, thank you for putting me in the right direction. The padding/margin did indeed have something to say stopping the animation half-ways. I still had problems with text inside the element, and deletion onEnd, but eventually found the answer myself. I also added a wrapper-div with
.information_messagesto allow for multiple.information_messageelements. Final result follows:Javascript:
HTML:
CSS: