JS DOM programs collection
JS program to show the concept of getElementById (DOM)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>counting typed characters</title>
</head>
<body>
Enter your text<br>
<textarea id="messagecount" oninput="charasCount();" rows="10" cols="10"></textarea>
<p>total characters you have types is:<span id="total">0</span></p>
<script>
function charasCount()
{
var i;
i=document.getElementById('messagecount').value;
document.getElementById('total').innerText=i.length;
}
</script>
</body>
</html>
No comments:
Post a Comment