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

JS imitates the editor's method of changing the width and height of the text box in real time_javascript skills

WBOY
Release: 2016-05-16 15:44:36
Original
1293 people have browsed it

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>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template