I am trying to delete the parent of a clone node in JavaScript because when i restore the saved table it creates a duplicate of the same table below the original. So I need to delete the original table and just display the child table.
function Save(){
var table = document.getElementById("sudoku");
clone = table.cloneNode(true);
}
//Create Restore Function
function Restore(){
document.getElementById("sudoku").parentNode.appendChild(clone);
table.parentNode.removeChild("table");
}
I have also tried this method I found on here on another thread but when I try use it stops the rest of my javascript working
document.getElementById("sudoku").parentNode.removeChild(document.getElementById("sudoku"));
thanks in advance
function Restore(){
var table = document.getElementById("sudoku"),
parent = table.parentNode;
parent.removeChild(table);
parent.appendChild(clone);
}
Note that listeners may be on the table that was removed so you could have to re-attach them.