0
What is the difference between innerHTML & innerText?
Which is better to use?
2 Respuestas
+ 2
innerText does not render HTML tags, innerHTML does. Be careful when you update an element's innerHTML with values from user inputs, even indirectly.
+ 2
innerText:
Retrieves and sets the content in plain text.
We can not insert the HTML tags.
It ignores the spaces.
It returns text without an inner element tag.
innerHTML:
Retrieves and sets the content in HTML format.
We can insert the HTML tags.
It considers the spaces.
It returns a tag with an inner element tag.