Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cloneNode in internet explorer

While executing the following code IE throws the error -- Object doesn't support this property or method -- referring to the cloneNode() method. 'i' is the loop counter, source and dest are both HTML select elements.

dest.options[dest.options.length] = source.options[i].cloneNode( true );

FF and Chrome behave as expected. Any ideas on how to get IE to execute cloneNode()? The IE 8 debugger shows source.options[i] does have a cloneNode() method.

Thanks.

like image 213
Mark Avatar asked Sep 06 '10 21:09

Mark


1 Answers

IE requires the

new Option()

construct.

document.createElement( 'option' );

or

cloneNode()

will fail. Of course, all options work as expected in a proper web browser.

like image 152
Mark Avatar answered Oct 20 '22 01:10

Mark