JavaScript element.innerText Property
JavaScript element.innerText Property
The element.innerText
property gets or sets the text content of the specified node, and all its descendants.
Note: If you set the innerText property to a specified element, all child nodes of that specified element are removed and replaced by a single Text node containing the specified string.
Note: The element.innerText
is easily confused with node.textContent, but there are important differences between the two.
- innerText will not return the text of elements that are hidden with CSS, but textContent will do.
- textContent returns the text content of all elements, whereas, innerText returns the content of all elements, except for <style> and <script> elements.
Get the innerText
Example
Syntax
Return Values
Value | Explanation |
---|---|
String | Returns a DOMString representing the rendered text content of an element. |
Set the innerText
Example
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.