Let's say I have the following HTML:
<div id='content'></div> I'd like to be alerted when height mutations occur on this element. I was hoping the MutationObserver class would help in this, but here is my problem with it:
document.querySelector('#content').style.height = '100px' It triggers my callback like expected, however normal user interactions won't trigger this, e.g., http://jsfiddle.net/wq4q9/2/
My question is, what is the best modern approach for checking if an element's height has changed?
No jQuery please.
targetthe textarea rather than#contentin your fiddle, it works in Firefox (in reference to the proposed dupe stackoverflow.com/questions/20294828/…). Your current fiddle is sort-of comparing apples and oranges, as you're asking us to manually resize the textarea, but programatically resize#content. If you programatically resizetextareainstead, the MutationObserver won't fire (jsfiddle.net/wq4q9/4).