title: replace position of DOM element and preserve its events
body: <p>I am writing a jquery plugin that gets a table and allow to change the columns order.<br>
  The code for putting the column that in position oldIndex in position newIndex is:</p>
  
  <pre><code>table.find('&gt; thead &gt; tr, &gt; tbody &gt; tr').each(function() {
      var row = $(this);
      var children = row.children();
      var source = $(children[oldIndex ]);
      var destination = $(children[newIndex ]);
  
      if (oldIndex != newIndex ) {
          destination
              .replaceWith(source)
              .appendTo(row);
      }
  });
  </code></pre>
  
  <p>The problem is that each td has events that came outside this code. When using <code>replaceWith</code>, it removes those events.   </p>
  
  <p>Any idea hoe can I replace position of DOM element and preserve its events?</p>