jQuery: How to get $(body)[0].scrollHeight with dynamic content?
<pre class="lang-js prettyprint-override"><code>$("#toggle").click(function() {
    $("p").toggle(function() {
        // $('body')[0].scrollHeight &lt;-- this is it, but not in my case
    });
});
</code></pre>

<pre class="lang-html prettyprint-override"><code>&lt;a id="toggle"&gt;Toggle&lt;/a&gt;

&lt;p&gt;content&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
...a hundred more &lt;p&gt;'s that enough to make the scrollbar appear...
&lt;p&gt;...&lt;/p&gt;
</code></pre>

<p>I'm trying to get the scrollHeight when the page content is dynamically changed.</p>

<p>The reason I don't want to use the method in the comment line is because I have other events depending on this dynamic scrollHeight, and I don't really want to write the same thing on every single click.</p>

<p>I'm looking for something like</p>

<pre class="lang-js prettyprint-override"><code>$('window').scrollHeightChanged(function() {
    // do this
    // do that
});
</code></pre>

<p>but not</p>

<pre class="lang-js prettyprint-override"><code>setInterval(function() {
    // check scrollHeight
}, 10);
</code></pre>

<p>by the way, I'v tried $('#wrapper').resize(), it only works in IE</p>

<h1>UPDATE</h1>

<p>I found myself a solution: the jQuery resize event plugin, which made resize() work on all elements. It's not exactly what I was looking for, but at least it detects element size change. <a href="http://benalman.com/projects/jquery-resize-plugin/" rel="nofollow">http://benalman.com/projects/jquery-resize-plugin/</a></p>
