Copy the contents of one table to another

In my current application, I need to copy the contents of one table to another ... With innerHTML setting, it works fine in FF ... but not in IE8 ... Here is the code I used to copy to FF:

getID("tableA").innerHTML = getID("tableB").innerHTML;
// getID is a custom function i wrote to provide a shorter version of document.getElementById();

Table A is empty (only the tbody tag exists). TableB is as follows:


table
  tbody
    tr
      td "Content" /td
      td "Content" /td
    /tr
  /tbody
/table

I already tried using nodeValue .. or appendData ... or outerHTML .. but nothing really worked ...

+3
source share
2 answers

Internet Explorer does not allow you to edit the inside of tables using innerHTML - that's all or nothing.

innerHTML , (.. , ), :

var source = document.getElementById('tableA');
var destination = document.getElementById('tableB');
var copy = source.cloneNode(true);
copy.setAttribute('id', 'tableB');
destination.parentNode.replaceChild(copy, destination);
+7

, , IE 8. , , . Internet Explorer innerHTML - innerHTML . . , tbody node replaceChild(), tbody .

0

Source: https://habr.com/ru/post/1706800/