title: How to use jquery correctly in SharePoint Web Part - jquery doesn't always fire
body: <p>I'm learning how to use jquery with SharePoint.  My example draws a red box inside the Content Editor Web Part when a link is selected.  My code works when the SharePoint page is in edit mode but not after I've left the page and returned in non edit mode.  The jquery function does not fire for some reason...  I'm missing something simple but not sure what.</p>
  
  <p>Thanks for any help.</p>
  
  <p>Kevin</p>
  
  <p>My master page for the site connects to the jquery-1.3.2.min.js file this way:</p>
  
  <pre><code> &lt;SharePoint:ScriptLink language="javascript" name="jquery-1.3.2.min.js" 
   Defer="true" runat="server"/&gt;
  </code></pre>
  
  <p>My Content Editor Web Part code looks like this:</p>
  
  <pre><code>&lt;style type="text/css"&gt;
  #box
  {
      background: red;
      width: 300px;
      height: 300px;
      display: none;
  }
  &lt;/style&gt;
  
  
  &lt;script type ="text/javascript"&gt;
      $(function() {
          $('a').click(function() {
              $('#box').slideDown(2000);
          });
      })
  &lt;/script&gt;
  
  &lt;div id="box"&gt;
  &lt;h1&gt;This is text in the box&lt;/h1&gt;
  &lt;/div&gt;
  &lt;a href="#"&gt;Display Box&lt;/a&gt;&lt;br /&gt;
  </code></pre>