title: jQuery: Call a function twice
body: <p>I'm trying to run a function twice. Once when the page loads, and then again on click. Not sure what I'm doing wrong. Here is my code:</p>
  
  <pre><code>$('div').each(function truncate() {
      $(this).addClass('closed').children().slice(0,2).show().find('.truncate').show();
  });
  
  $('.truncate').click(function() {
  
      if ($(this).parent().hasClass('closed')) {
          $(this).parent().removeClass('closed').addClass('open').children().show();
      }
  
      else if ($(this).parent().hasClass('open')) {
          $(this).parent().removeClass('open').addClass('closed');
          $('div').truncate();
          $(this).show();
      }
  
  });
  </code></pre>
  
  <p>The problem is on line 13 where I call the <code>truncate();</code> function a second time. Any idea why it's not working?</p>
  
  <p><strong>Edit</strong> jsFiddle here: <a href="http://jsfiddle.net/g6PLu/" rel="nofollow">http://jsfiddle.net/g6PLu/</a></p>