There are different opinions on the Internet, and the content of textarea has been tested. replace (/\ n/g, "<br/>") solves the problem and passes the test in IE6/7/8/9 Firefox/3.6.13 chrome10.0.648.82. The sample code is as follows:
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> YES! B/S! Article Example page </title>
<Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>
<Script type = "text/javascript">
Function testabc ()
{
Var content = $ ("# test"). val (). replace (/\ n/g, "<br/> ");
Alert (content );
}
</Script>
</Head>
<Body>
<Textarea id = "test" rows = "4" style = "width: 406px; overflow-y: auto;"> </textarea> <br>
<Input type = "button" onclick = "testabc ()" value = "test"/>
</Body>
</Html>
Result:
I won't talk about the following processing.