title: How do I copy the data of an element with jQuery?
body: <p>I need to copy data values from one element to another, but jQuery's clone() method doesn't clone the data. And I can't iterate over the data either:</p>
  
  <pre><code>element.data().each
  </code></pre>
  
  <p>because <code>data()</code> is a function and not a jQuery object. It seems I have to keep a separate list of attribute names and reference those but that seems too hacky. So how can I do either of these:</p>
  
  <p>a) Iterate over data items<br>
  OR<br>
  b) <code>clone()</code> an element with its data.</p>