title: jQuery: find H2 id and append link with same id
body: <p>I have the following code and I want for every <code>H2</code> with <code>id</code> attribute I would create an anchor link. I can not get it to work properly...</p>
  
  <pre><code>&lt;div id="mydiv"&gt;
      &lt;h2 id="first"&gt;first&lt;/h2&gt;
      &lt;h2&gt;second&lt;/h2&gt;
      &lt;h2 id="third"&gt;third&lt;/h2&gt;
  &lt;/div&gt;
  
  .sls {color: red;font-size: 12px;}
  
  $('#mydiv')
  .find('h2[id]')
  .append(' &lt;a href="http://www.test.com/page.html#'+ $('h2[id]')
  .attr('id') +'" class="sls"&gt;Link&lt;/a&gt;');
  </code></pre>
  
  <p><strong><a href="https://jsfiddle.net/ivanionut/1ohh2hws/" rel="nofollow noreferrer">https://jsfiddle.net/ivanionut/1ohh2hws/</a></strong></p>
  
  <p>Thanks for your help.</p>