can't find a question that addresses this exactly so here goes. I am trying to use jquery to animate a div between 2 heights that are both unknown until the page is loaded. The heights will be based on the length of a string length being fed into the div. On hover, an expanded version of the first string will be fed in, and as this happens, I want the div to expand to accommodate. When the user is no longer hovering over the div, it should recoil to its original state. Here, I think I've got the original height part down, but is there a way to get the unknown height of what the div would look like on the hover? I've heard the DOM stores the max height of a div which you can access with scrollheight, but I've played around with that and it doesn't seem to work. Here's the code:
var originalHeight = $("#0").outerHeight(true);
var newHeight = ??? // tried this: $("#0")[0].scrollHeight;
$("#0").hover(function(text) {
if (excerptsShort[0].length >= 200) {
$(this).animate(text.type === "mouseenter"
? { height: newHeight }
: { height: originalHeight });
$(this).html(text.type === "mouseenter"
? excerptsLong[0] + "..."
: excerptsShort[0] + "..."
)}
});