I have a nightmare with a simple function!
I want him to:
- read the height of the div with the existing content in it
- Refresh div with new content (provided by function)
- Read the height that the div should be, but set it to its original height.
- Animate the height of the div to customize and set new content.
The code is as follows:
// function to display status content by animating the height of the status message function slideStatus(content){ // get current height var status_origheight = $("#status-message").height(); // insert new content $("#status-message").html(content); // get new height var status_newheight = $("#status-message").height(); // set the height to the orig value, hiding overflow content $("#status-message").height(status_origheight).css("overflow","hidden"); // animate the div to the new height $("#status-message").animate({height:"+="+(status_newheight - status_origheight)+""}, 1000); }
When I run this, it seems to ignore the fact that the content has changed, and just use the original height (so don't do the animation because it thinks the height hasn't changed).
Please help if you can! It drives me crazy.
source share