... if (myArray[0] == 1) { var oldNode = getElementById(id); oldNode.parentNode.replaceChild(myArray[1], oldNode); } ...