×

Html & Html5

it training classes Logo

The World's best Software Development Study Portal

Javascript innerText Property



The innerText property of JavaScript is used to get or set the text inside an HTML element and its descendants. The innerText has a similar working phenomenon to innerHTML. Both properties manipulate the content of an HTML element but with different aspects. The innerText focuses on the textual content and the innerHTML considers the HTML content of an element.

Javascript innerText property can be used to write the dynamic text on the HTML document.

<html>
<body>
<script>
function validate() {
var msg;
if(document.myForm.userPass.value.length>5){
msg="good";
}
else{
msg="poor";
}
document.getElementById('mylocation').innerText=msg;
}
</script>
<form name="myForm">
<input type="password" value="" name="userPass" onkeyup="validate()">
Strength:<span id="mylocation">no strength</span>
</form>
</body>
</html>

Online

Strength:no strength








JS training insitute | Best IT Training classes in Gurgaon | Web Designing Training Institute