title: How can I make function for multiple instances
body: <p>I have written a small code to show hide element and its working fine. What can I do to make it work on multiple instances. How can I make code for multiple instances</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;style&gt;
  .heading{ font-size:18px}
  .paragraph{ font-size:12px; height:0; overflow:hidden; background-color:#CCCCCC;}
  .close{ color:#FF0000; font-weight:bold;}
  
  &lt;/style&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;div&gt;
      &lt;h1 class="heading"&gt;This is Heading&lt;/h1&gt;
      &lt;p class="paragraph"&gt;This is paragraph. This is paragraph. This is paragraph. This is paragraph. This is paragraph. This is paragraph. This is paragraph.&lt;br/&gt;&lt;span class="close"&gt;Close&lt;/span&gt; &lt;/p&gt;
  &lt;/div&gt;
  &lt;div&gt;
      &lt;h1 class="heading"&gt;This is Heading&lt;/h1&gt;
      &lt;p class="paragraph"&gt;This is paragraph. This is paragraph. This is paragraph. This is paragraph. This is paragraph. This is paragraph. This is paragraph.&lt;br/&gt;&lt;span class="close"&gt;Close&lt;/span&gt; &lt;/p&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  $('h1.heading').click(function(){
  $clickedElement=$(this);
  $('$clickedElement.paragraph').animate({'height':'50px'},1000);
  })
  
  $('.close').click(function(){
  $('.paragraph').animate({'height':'0px'},1000);
  })
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>