Hi,
The below program will create a text area that dynamically resizes with the text the user enters in it.
Source code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Textarea dynamically increase </title>
<style>
textarea {
overflow: hidden;
}
</style>
<script>
var te = document.querySelector('textarea');
te.addEventListener('keydown', resizeTextarea);
function resizeTextarea(ev) {
this.style.height = '24px';
this.style.height = this.scrollHeight + 12 + 'px';
}
</script>
</head>
<body>
<textarea rows="3" cols="80"></textarea>
</body>
</html>
-------------------------------------@@@@@@@@@@@@@@@@----------------------------------
No comments:
Post a Comment