TextArea Internal line break implementation

Source: Internet
Author: User

When using textarea, there is a need to do a custom line, rather than through the textarea fixed width to automatically wrap, in fact, in the HTML can be directly through <br/> to line, but also think of \ n to achieve the line, the result is not bird you.

<cols= "$" rows= "5"  ID= "Textareaid"  >"Adfsadfs<br/>fddsadfds \ n dfadadf"</textarea  >

Baidu a few online did say can use \ r \ n to achieve the line, if only compatible with Microsoft system directly \ n can, but the experiment does not, the back thought is not necessary through the JS assignment can be realized, so the following code appears:

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title></Head><Body>    <textareacols= " the"rows= "5"ID= "Textareaid">"Adfsadfs<BR/>Fddsadfds \ DFADADF "</textarea>    <Scripttype= "Text/javascript">Document.onclick=function() {alert (1); varStr='5456455D4FGDFGDGDG \ Dsfafdadfadfafa'; document.getElementById ("Textareaid"). Value=str; }    </Script>    </Body></HTML>

Successful implementation of the textarea, so I infer that in order to achieve textarea, the dynamic JS must be assigned to the line.

Test address

Note: There are instructions on Baidu to achieve compatible Linux,unix,Mac OS, window, you can change \ r \ n, but I use \ n in the Apple system to achieve a line,Linux,unix The system does not test the personal feeling, solve

The individual knows limited, if has the wrong place also to be correct, the common study common progress!

TextArea Internal line break implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.