JavaScript Inner Text
The `innerText` property is used to display dynamic text on an HTML document,
treating the text as plain text rather than interpreting it as HTML.
It is commonly used on web pages to generate dynamic content, such as
displaying validation messages or indicating password strength.
Example
In this example, we will display the password strength when a key is released
after being pressed.
<!DOCTYPE
html>
<html>
<head>
<title>innerText
Example</title>
</head>
<body>
<h1 id="title">Hello,
World!</h1>
<button
onclick="changeText()">Change Text</button>
<script>
function changeText() {
// Get the element by ID
const titleElement =
document.getElementById('title');
// Set new text content
titleElement.innerText = 'Text
Changed!';
}
</script>
</body>
</html>
Output :
Initial State (before clicking the button):
Hello, World!
[Change Text] (button)
After Clicking the "Change Text" Button: