InnerText and InnerHTML : Introduction « DOM Node « JavaScript Tutorial






innerText returns only the text portions.

innerHTML returns the HTML code for all elements and text.

The following table lists the different values for innerText and innerHTML based on certain code.

CodeinnerTextinnerHTML
Hello world
"Hello world""Hello world"
Hello world
"Hello world""Hello world"
""""


23.1.Introduction
23.1.1.InnerText and InnerHTML
23.1.2.Get node type
23.1.3.Get node name
23.1.4.Get node value