Summary of Textarea line break issues in HTML

Summary of Textarea line break issues in HTML
Recently, I encountered a problem of whether the data can be truly stored row by row when transferred to Textrea. Here is a summary:

Problem description:
For example, get data into a TextArea, such as "AAA BBB", and want to store this text in the TextArea in real lines, rather than displaying it in lines (the so-called real line storage means that the data of this TextArea is still stored in lines when it is posted to the Textarea of ​​another page)

Problem Solved 1:
When the data is submitted at the beginning, the format is AAA<BR />BBB, but this is to display line breaks. In fact, it is not really stored in rows in the TextArea. Because when it is submitted to another TextArea, it will display AAABBB instead of line breaks. Therefore, it is only displayed as stored in rows.

Question Basics:
The line break in HTML is <BR />, while the line break in TextArea is /n

Problem Solved 2:
Submit the data first and then use Javascript to replace <BR /> and /n. When submitting, <BR /> is still used as a separator. After submitting,

Copy code
The code is as follows:

<script>
// Line break and carriage return
var haha=document.getElementById("SendTextArea").value;
haha=haha.replace('
','/n');
document.getElementById("SendTextArea").value=haha;
</script>

That’s it!

<<:  How can the front end better display the 100,000 pieces of data returned by the back end?

>>:  28 Famous Blog Redesign Examples

Recommend

Summary of front-end knowledge in the Gokudō game

background In the early stages of learning Japane...

How to use axios to filter multiple repeated requests in a project

Table of contents 1. Introduction: In this case, ...

Solution to the problem that the InnoDB engine is disabled when MySQL is started

Find the problem Today at work, when copying tabl...

WeChat applet implements user login module server construction

I chose node.js to build the server. Friends who ...

A brief discussion on CSS height collapse problem

Performance For example: HTML: <div class=&quo...

...

Using jQuery to implement the carousel effect

What I bring to you today is to use jQuery to imp...

Implementation of IP address configuration in Centos7.5

1. Before configuring the IP address, first use i...

Docker uses busybox to create a base image

The first line of a Docker image starts with an i...

About the garbled problem caused by HTML encoding

Today a junior student asked a question. The HTML...

How to configure multiple tomcats with Nginx load balancing under Linux

The methods of installing nginx and multiple tomc...

Examples of implementing progress bars and order progress bars using CSS

The preparation for the final exams in the past h...

Global call implementation of Vue2.x Picker on mobile terminal

Table of contents What is the Picker component Pr...

25 Ways and Tips to Increase Web Page Loading Speed

Introduction <br />Not everyone has access t...