title: jquery .click() event on dynamic anchor does not work
body: <p>I have a <code>&lt;span class="clickspan"&gt;Some text here&lt;/span&gt;</code></p>
  
  <p>What I'm trying to do is when the <code>span</code> is clicked a dynamic anchor is created for the clicked span and then <code>click</code> event is triggered with jquery on the dynamic anchor.</p>
  
  <pre><code>$('.clickspan').on('click', function(){
  
      // Method 1: Replace span with dynamic anchor
      $(this).replaceWith('&lt;a id="1234" href="www.example.com"&gt;&lt;/a&gt;');
  
      // None of the following works
      $('#1234').trigger('click');
      $('#1234').click();
  
      // Method 2: Insert dynamic anchor inside the span
      var theSpan = $(this).wrapInner('&lt;a href="'+data.msg+'" donwload&gt;&lt;/a&gt;'),
          anch = theSpan.find('a');
  
      // this click event on the dynamic anchor inside the span causes the click
      // event on the parent span and to run the entire script all over again.
      anch.click(); 
  });
  </code></pre>
  
  <p>I've been struggling with this for a while and exhausted all ideas, so I'd appreciate any suggestion.</p>
  
  <p><strong>SOLVED</strong></p>
  
  <p>The method and the source suggested by @Ninsly in the comment below fixed the issue. The following worked:</p>
  
  <pre><code>$('#1234')[0].click();
  </code></pre>
  
  <p>Sorry for taking everybody's time. I was not aware of the need to use <code>[0]</code>.</p>