Hello! I want to copy the content of one div into another one, however, I got an err saying that the div selected is null. Why is this? How can I solve it?
let foo= document.getElementById("foo").innerText;
let baz= document.getElementById("baz").innerText;
foo= baz;
should I put an event listener with type DOMContentLoaded? I don’t know why the foo and baz are null. They exist in HTML.
let foo= document.getElementById("foo").innerText;
let baz= document.getElementById("baz").innerText;
foo= baz;
foo and baz variable as you described, simply text not a html element.
Inside html elements foo and baz simply text not a variable, so dom doesn’t know
they are variable. It simply put ‘foo’ and ‘baz’ string.
What you can do as a solution would be, you can store html elements as variables not their innerText, and when the DOMLoaded you can change their innerText by referencing those variables you created.