Adding data to hyperlink dynamically on click of another button by jQuery
<p>I have an anchor with id='peter'. When i click this, the hyperlink of anchor 'jack' must now add the id of 'peter' at the end of its hyperlink. </p>

<pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;      &lt;/script&gt;
    &lt;script&gt;
       $(document).ready(function(){
           $('#peter').click(function(){
              $('#jack').attr('href', '?id=peter');
           });
       });
    &lt;/script&gt;
  &lt;/head&gt;

&lt;body&gt; 
&lt;a href="" id="peter"&gt;Click&lt;/a&gt;
&lt;a href="http://www.yahoo.com" id="jack"&gt;Yahoo&lt;/a&gt;
&lt;/body&gt; 
&lt;/html&gt;
</code></pre>

<p>Expectation: </p>

<blockquote>
  <p>the hyperlink of second anchor must now be -
  <a href="http://www.yahoo.com?id=peter" rel="nofollow">http://www.yahoo.com?id=peter</a></p>
</blockquote>

<p>Can someone help me out how to add this id by 'jQuery'?</p>