Set multi-line text box [textarea] to automatically generate height
This time I will bring you settingsMulti-line text box[textarea] automatically generates height, set multi-line text box[textarea] to automatically generate heightWhat are the precautions, The following is a practical case, let’s take a look.
Implementation functions:
1/Automatically increase the height of a row when the textarea wraps a new line
2/Automatically reduce the height of a row when the textarea deletes a row Dependency: jquery.xxx.js Needed for work I use similar functions but find it inconvenient to import other files when using a plug-in, so I wrote a
textarea jquery plug-in
<p class="form-group"> <label class="col-sm-3 control-label no- padding-right " for="form-field-5"> 内容</label> <p class="col-sm-9"> <textarea class="col-sm-8" id="form-field-5" placeholder="请输入内容..."></textarea> </p> </p>
jQuery.extend({ textareaAutosize_dc: function() { $("textarea").on("keyup", function(e) { var current EnterCount = $(this).val().split("\n").length; var lineHeight = Number($(this).css(" line-height ").replace("px", "")); var enterCount = $(this).attr("enterCount"); if (currentEnterCount < enterCount && enterCount != undefined) { //每行减掉固定行高 $(this).height($(this).height() - lineHeight); } else if (currentEnterCount > enterCount) { //每行加入固定行高 $(this).height($(this).height() + lineHeight); $(this).attr("enterCount", currentEnterCount); } //记录当前行高 $(this).attr("enterCount", currentEnterCount); }); } }); //调用自动高度 $.textareaAutosize_dc();
I believe you have mastered the method after reading the case in this article, please come for more exciting information Pay attention to other related articles on php Chinese website!
Recommended reading:
Jquery Mobile Custom Button Icon Steps Detailed Explanation
Jquery Mobile Custom Button Icon Steps Detailed Explanation
The above is the detailed content of Set multi-line text box [textarea] to automatically generate height. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



WPS is a powerful office software that can help us complete various office tasks efficiently. Among them, automatically generating table of contents page numbers is a very practical function. It can greatly improve the work efficiency of users, so the editor of this website will bring you this article to introduce in detail how to use WPS to automatically generate directory page numbers. I hope it can help everyone in need. How to automatically generate table of contents page numbers for a wps directory. First, open the wps group document, enter the content of the table of contents to be generated in the blank space, and then select the styles of title 1, title 2, and title 3 in the start menu bar. 2. Then after setting it up, we click the [Reference] function. After clicking, in the reference toolbar, here we click [Directory]; 3. Finally click

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Select the style of the catalog in Word, and it will be automatically generated after the operation is completed. Analysis 1. Go to Word on your computer and click to import. 2After entering, click on the file directory. 3 Then select the style of the directory. 4. After the operation is completed, you can see that the file directory is automatically generated. Supplement: The table of contents of the summary/notes article is automatically generated, including first-level headings, second-level headings and third-level headings, usually no more than third-level headings.

Tags are a commonly used HTML element used to add line breaks in web content. Sometimes, however, the pre-existing height of line discontinuity may be deemed insufficient and the gaps between consecutive lines of written material need to be increased. In this discussion, we'll explore various ways to modify the height of a label, including using the CSS line-height property and adding auxiliary line wrapping elements. Whether you are a junior or an experienced web developer, this manual will give you a comprehensive understanding of how to adjust the height of labels in web design. Methods We will see two different methods to visibly change the height of the br tag. They are as follows - Use CSSline-height property to add extra line breaks Method One: Using CSSline-

With the continuous development of Internet technology, API has become an important way to realize data interaction between applications. In the process of writing APIs, document writing and maintenance inevitably become an important issue. However, the traditional way of manually writing and maintaining API documentation is inefficient and error-prone, and is not suitable for projects with continuous iteration. Using PHP to automatically generate API documents can effectively improve efficiency and reduce errors. This article will introduce how to use PHP to automatically generate API documents. Manual

How to develop a WordPress plug-in that automatically generates e-books. With the popularity of social media and e-readers, e-books have become one of the important ways for people to obtain and share knowledge. As a WordPress developer, you may be faced with the need to create and publish e-books. To simplify this process, we can develop a WordPress plugin that automatically generates e-books. This article will teach you how to develop such a plug-in and provide code examples for reference. Step 1: Create the basic file structure of the plugin first

How to automatically generate equals() and hashCode() methods using Records class in Java14 In Java programming, we often need to write equals() and hashCode() methods for our classes. These two methods are very important when dealing with equality and hash codes of objects. To simplify this process, Java14 introduces a new Records class. The Records class provides a way to simplify writing equals() and hashCode

You can use the readonly attribute, disabled and readwrite attributes to set the textarea read-only. Detailed introduction: 1. readonly attribute, the value of the readonly attribute is readonly; 2. disabled attribute, the content of the <textarea> element cannot be changed, because the value of the disabled attribute is disabled; 3. readwrite attribute, the content of the <textarea> element can Changes and more.
