title: jQuery bind on change of length
body: <p>I have a table that is being updated by Ajax. I want to do something when new data is added to it, but since the change is in appearance, it should be done by the preloaded JS rather than Ajax returned JS.</p>
  
  <p>I am looking for something like <code>$('table tr').length.change( ... )</code>, So I can do something like this</p>
  
  <pre><code>$('table tr').length.change( function() {
    if ($('table tr').length&gt;1) $('table').show() else $('table').hide()
  }
  </code></pre>
  
  <p>The Ajax-returned JS will do something like this (say in Rails)</p>
  
  <pre><code>$('table').append('&lt;tr&gt; &lt;td&gt;&lt;%= @person.name %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= @person.age %&gt;&lt;/td&gt; &lt;/tr&gt;')
  </code></pre>
  
  <p>(in Rails this will be in some <code>/app/views/container_name/method_name.js.erb</code>)</p>