You can simply set the innerHTML
of p
directly:
p.innerHTML = ' ';
Please note that Element.querySelectorAll()
"returns a non-live NodeList of all elements descended
from the element on which it is invoked that match the specified group of CSS selectors."
So by default, the element you are calling this on p
will not be included in the returned NodeList
.