How I discovered ‘cloneNode’

So I was trying to copy all the elements from one element. I thought this should be sweet.

But no. It seemed that random option elements were disappearing from the initial element worked a treat; the original node and renamed it, which I will probably do when I get in to work tomorrow. I’m not sure which method is more resource-hungry, but I’m guessing it’s the loop.

I’m not sure whether I’m supposed to be using cloneNode or not, but it seems to work in the versions of IE and Firefox that I’m developing in. Proper testing is yet to see if it works in all our supported browsers.

FYI: The boolean parameter that cloneNode accepts tells the method whether or not to clone child nodes also. This is where I found out about cloneNode.

This entry was posted in Coding, JavaScript. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *