title: Use jQuery click to handle anchor onClick()
body: <p>I have a set of dynamically generated anchor tags in a for loop as follows:</p>
  
  <pre><code>&lt;div id = "solTitle"&gt; &lt;a href = "#"  id = "' + tagId + '" onClick = "openSolution();"&gt; ' + solTitle + '&lt;/a&gt;&lt;/div&gt; &lt;br&gt;';
  </code></pre>
  
  <p>Once this code is executed the html output for one of the case would look like:</p>
  
  <pre><code>&lt;div id = "solTitle"&gt; &lt;a href = "#"  id = "solution0" onClick = "openSolution();"&gt;Solution0 &lt;/a&gt;&lt;/div&gt; &lt;br&gt;
  
  &lt;div id = "solTitle"&gt; &lt;a href = "#"  id = "solution1" onClick = "openSolution();"&gt;Solution1 &lt;/a&gt;&lt;/div&gt; &lt;br&gt;
  </code></pre>
  
  <p>Now I want different texts to be displayed on clicking the above links.
  openSolution() looks like this:</p>
  
  <pre><code>function openSolution() {
      alert('here');
      $('#solTitle a').click(function(evt) {
          evt.preventDefault();
          alert('here in');
          var divId = 'summary' + $(this).attr('id');
  
          document.getElementById(divId).className = '';
  
      });
  }
  </code></pre>
  
  <p>When I execute it and click on either of the  links, the flow doesnot come inside the jquery click handler.  I checked it by the above alerts used. It only displays the alert - 'here' and not the alert - 'here in'. 
  On clicking the link second time, everything works perfectly with correct value of divId.</p>