tags:

views:

5618

answers:

1

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:

element.data().each

because data() 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:
a) Iterate over data items
OR
b) clone() an element with its data.

+1  A: 

This question discusses cloning in JQuery, and the difference between a deep copy and a shallow copy.

The accepted answer is that given by John Resig, who knows a thing or two about JQuery!

ConroyP