0

What is the difference between innerHTML & innerText?

Which is better to use?

22nd Oct 2021, 9:36 AM
Fꫀⲅძ᥆͟ᥙ᥉᯽
Fꫀⲅძ᥆͟ᥙ᥉᯽ - avatar
2 odpowiedzi
+ 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.
22nd Oct 2021, 9:50 AM
Ipang
+ 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.
22nd Oct 2021, 9:50 AM
Omkar Kamat
Omkar Kamat - avatar