fix JavaScript to replaceChild instead of innerHTML