title: Copy events from one element to other using jquery
body: <p>I have DOM is like this:</p>
  
  <pre><code>&lt;a href='javascript:void(0)' id='link1'&gt;Element with  events bound initially&lt;/a&gt;
  &lt;a href='javascript:void(0)' id='link2'&gt;Element to which events are bound in future&lt;/a&gt;
  </code></pre>
  
  <p>And this javascript:</p>
  
  <pre><code>$(function(){
      $('#link1').bind('click',function(){alert('do something to make me happy');})
  });
  </code></pre>
  
  <p>Now some time in future i want to copy all events bound on link1 to link2. I am doing it as written below please suggest some better way if possible or available.</p>
  
  <pre><code>var _elmEvents = $(#link1).data('events');
  
  if (_elmEvents) {
      $.each(_elmEvents, function (event, handlers) {
          $.each(handlers, function (j, handler) {
              $('#link2').bind(event, handler);
          });
      });
  }
  </code></pre>