javascript - Textarea does not auto resize with pre-filled value -
i have textarea resizes based on type. used solution kylemit
it.
html:
<textarea onkeyup="textareaadjust(this)" style="overflow:hidden"></textarea>
js:
function textareaadjust(o) { o.style.height = "1px"; o.style.height = (25+o.scrollheight)+"px"; }
this works fine when user has type on textarea textarea has pre-filled value in it. resizing not work pre-filled value. resizes when user starts typing on textarea.
example of pre-filled textarea
<textarea onkeyup="textareaadjust(this)" style="overflow:hidden">identify, formulate, research literature, , analyze user needs , taking them account solve complex information technology problems, reaching substantiated conclusions using fundamental principles of mathematics, computing fundamentals, technical concepts , practices in core information technologies, , relevant domain disciplines.</textarea>
is there way can solve problem through css or js?
you have use these 2 lines of code out of function well,so used @ time of page load well,
you give id text area , call code in manner,and call on page load,it work shown below
<!doctype html> <html> <head> <meta charset="iso-8859-1"> <title>insert title here</title> </head> <body onload="callonpageload()"> <script> function callonpageload(){ document.getelementbyid("textareaex").style.height="1px"; document.getelementbyid("textareaex").style.height=(25+document.getelementbyid("textareaex").scrollheight)+"px"; } </script> <textarea onkeyup="callonpageload()" id="textareaex" style="overflow:hidden">identify, formulate, research literature, , analyze user needs , taking them account solve complex information technology problems, reaching substantiated conclusions using fundamental principles of mathematics, computing fundamentals, technical concepts , practices in core information technologies, , relevant domain disciplines.</textarea> </body> </html>
Comments
Post a Comment