Textarea has a high degree of automatic growth of errors.

var scroll_Height = $("-sharpcontent").get(0).scrollHeight;
      $("-sharpcontent").css("height",scroll_Height + "px");

      $("-sharpcontent").on("input", function() {
        var scroll_Height = $("-sharpcontent").get(0).scrollHeight;
        $("-sharpcontent").css("height",scroll_Height + "px");
      });
<textarea name="content" id="content" class="normal_input_admin" row="1"><?=$data["content"];?></textarea>

what"s a little weird is that
when I press enter, it always increases. It all looks normal
, but when I want to go back to delete to delete text (each line)
his height only goes down 1px
suppose I press Enter three times and the height is 150px
but I want to eliminate that when these three lines become one line, his height will be like 148px. Change the true height without losing it to me
what"s the problem?

Apr.21,2021

but when I want to go back to delete to delete the text (each line), his height will only be 1px down

reason:

    The height value of
  1. scrollHeight is the content area + padding,
  2. css ('height') is the content area + padding + border

in this example, from the phenomenon you describe, textarea defaults to 1px border and 0px padding, that is,
actually scrollHeight has been 2px less than css ('height').
when, css (' height' is assigned to a smaller scrollHeight, than it every time the input event is triggered, the phenomenon you see will appear: "when delete deletes the text (each line), his height will only be deducted by 1px." it's not 1px, it's 2px.

the solution can be provided by @ Moon Shadow. The principle is that each time an input event is triggered, cancel the height of the textarea (this.style.height = 'auto'), and a scroll bar appears. The purpose of this is so that the scollHeight will be equal to the actual height of the text . If you omit this step, you will find that the high scrollHeight will not change when you delete the text.

finally rewrite Yueying's answer as follows, can avoid slight textarea jitter in his solution .

  https://blog.csdn.net/zhuogan.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaa3ce-1fc2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaa3ce-1fc2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?