<div class= "Form-group" > <label class= "col-sm-3 control-label no-padding-right" for= "form-field-5" > Content </label> <div class= "col-sm-9" > <textarea class= "col-sm-8" id= "form-field-5" placeholder= "Please enter the content: ." ></textarea> </div></div>
$.extend ({textareaautosize_dc:function () {$ ("textarea"). On ("KeyUp", function (e) {var currententercount=$ (this). val (). Split ("\ n"). Length;var Lineheight=number ($ (this). CSS ("Line-height"). Replace ("px", "")); height ( lineheight* (currententercount+1));}). Fn.extend ({textareaautosize_dc:function () {$ (this). In ("KeyUp", function (e) {var currententercount=$ (this). Val (). Split ("\ n"). Length;var Lineheight=number ($ (this). CSS ("Line-height"). Replace ("px", "")); height (lineheight * (currententercount+1));}); /Call Automatic height//$.textareaautosize_dc ();//Set all textarea height automatically $ ("textarea"). TEXTAREAAUTOSIZE_DC ();//Specify a specific textarea height automatically
Principle: is actually the text box height = row Height * (newline number +1)
1-minute implementation of multiline text box [textarea] Automatic height jquery plugin