what is the different between innerHTML and textContent | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

what is the different between innerHTML and textContent

in JAVASCRIPT

18th Mar 2022, 11:17 AM
Muhammad Ayaz
Muhammad Ayaz - avatar
2 Answers
+ 1
The textContent property: This property is used to get or set the text content of the specified node and its descendants. The innerHTML property: This property is used to get or set the HTML content of an element. see an example here - https://www.geeksforgeeks.org/difference-between-textcontent-and-innerhtml/
18th Mar 2022, 11:23 AM
Shaurya Kushwaha
+ 1
The text output with innerHTML can be formated with HTML / CSS statements. This example shows it: https://code.sololearn.com/WKzTAH2PqetR/?ref=app
18th Mar 2022, 11:48 AM
JaScript
JaScript - avatar