auto expand textarea using JavaScript
![]() |
| auto expand textarea using JavaScript |
use the below codes to implement auto expands textarea using JavaScript..
index.html
<html>
<head>
<style>
textarea
{
overflow:hidden;
border-radius:5px;
}
</style>
<script type="text/javascript">
function expands()
{
var val=document.getElementById("content").scrollHeight;
var h=document.getElementById("content").offsetHeight;
var cal=parseInt(h)-2;
if(val>cal)
{
h=h+50
document.getElementById("content").style.height=h;
}
}
</script>
</head>
<body>
<h3>increase textarea height dynamically using JavaScript</h3>
<textarea id="content" rows="2" cols="20" onkeyup="expands();" placeholder="Write Some Thing..">
</textarea>
</body>
</html>
That's it Friends how to implement auto expands textarea using JavaScript..
Stay with us for more codes..Thank you..


No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.