I have a parent and I add a child to it. After that I append <br>
to the parent's innerHTML
, but after that the child's innerHTML
can't be changed anymore. What's going on here? Why isn't the final result "bbb"?
But if you comment out container.innerHTML += "<br>"
, it does change to "bbb".
let container = document.createElement('div')
document.body.appendChild(container)
let child = document.createElement('div')
child.innerHTML = "aaa"
container.appendChild(child)
container.innerHTML += "<br>"
child.innerHTML = "bbb"
line doesn't give an error, in fact it logs `