Home >Web Front-end >JS Tutorial >JS imitates the editor's method of changing the width and height of the text box in real time_javascript skills
The example in this article describes the method of JS imitating the editor to change the width and height of the text box in real time. Share it with everyone for your reference. The details are as follows:
Here is a demonstration of how to change the size of the text box, including width and height, in real time in a JS imitation editor. In some online editors, such as eWebEditor, there is a function that allows the text box to continuously increase or decrease. How is this function implemented to adapt to the size of the page? Please refer to this program, I believe you will benefit from it.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-editor-cha-width-height-codes/
The specific code is as follows:
<html> <head> <title>改变文字区域的高宽</title> <script language="javascript"> <!-- function addrows(){ rows = form1.txt.rows; rows++; form1.txt.rows = rows; } function addcols(){ cols = form1.txt.cols; cols++; form1.txt.cols = cols; } //--> </script> </head> <body> <form name="form1"> <textarea name="txt"></textarea> <input type="button" value="增加高" onClick="addrows()"> <input type="button" value="增加宽" onClick="addcols()"> </form> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming design.