1
If I create an element and already add a class to it like this:
let paragrafo = document.createElement('p').classList.add('text')
Then try to add a child element to it like this:
text = document.createTextNode('texto')<br>
paragrafo.appendChild(text)
Keeps making the mistake of: Cannot read property 'appendChild' of undefined
.
If I change and try to add with classname of error : paragrafo.appendChild is not a function
But if I take the classList/classname from above, and don’t add a class works normal, however I need to add this class. Why I have this result and how can I create the element and then add the class using pure Javascript only?