How can I programmatically copy all of the style attributes from one DOM element to another

Posted by stu on Stack Overflow See other posts from Stack Overflow or by stu
Published on 2010-04-26T17:21:32Z Indexed on 2010/04/26 17:23 UTC
Read the original article Hit count: 211

Filed under:
|
|

I have a page with two frames, and I need to (via javascript) copy an element and all of its nested elements (it's a ul/li tree) and most importantly it's style from one frame to the other.

I get all the content via assigning innerhtml, and I am able to position the new element in the second frame with dest.style.left and dest.style.top and it works. But I'm trying to get all the style information and nothing's happening.

I'm using getComputedStyle to get the final style for each source element as I loop through each node then and assigning them to the same position in the destination nodelist and nothing happens to visually change the style.

What am I missing?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dom