I think jQuery .clone()
does a deep copy and both objects evolve independently. But is it possible to do a shallow copy in the sense that both objects share the same properties and methods so that whenever one changes the other does as well?
Asked
Active
Viewed 2,355 times
0

Mat
- 202,337
- 40
- 393
- 406

bingjie2680
- 7,643
- 8
- 45
- 72
-
http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object – Jeff Aug 21 '11 at 09:13
-
1Maybe I'm missing something, but `.clone()` does not clone *objects*, it clones *DOM elements*. Do you want to have DOM elements share the same attributes? I don't think that is possible. Maybe if you describe what you actually want to do, we can give some suggestions. – Felix Kling Aug 21 '11 at 09:16
-
well...basically, what I want is to copy a dom element, for both two elelments, whenever one element is clicked the other should be clicked as well. whenever one's text is changed the other should also be changed,,etc...hope this is clear. – bingjie2680 Aug 21 '11 at 09:23
-
OK, this is not possible by just cloning (or whatever) them. You would have to set up event handlers and manage the synchronization yourself. – Felix Kling Aug 21 '11 at 09:26
1 Answers
0
With respect to your comment, this is not possible by just cloning (or whatever) the elements. You would have to set up event handlers and manage the synchronization yourself.

Felix Kling
- 795,719
- 175
- 1,089
- 1,143