Javascript implements a function for automatically wrapping custom-length text.

Source: Internet
Author: User

Many of my friends always find that some English will open the original good table and cause deformation during webpage creation. Although style = "table-layout: fixed; word-wrap: can be used: break-word; word-break: break-all "to solve this problem, but sometimes the content is hidden due to incomplete display, and the effect of automatic line feed is not achieved.

So I want to write a function like this to fix this defect. This function is very simple, but it only provides a way to solve this problem.

Function fnAddBr (id, iPerLineLen ){.....}
Id is the id of the text block to be modified, and iPerLineLen is the length of each line.
<! Doctype html public "-// W3C // dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd"> <ptml> <pead> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312 "/> <title> Untitled Document </title> </pead> <body> when I create a webpage, the content I add always supports tables horizontally after the webpage is generated. wide, it's really ugly; after I added the code style = "table-layout: fixed; word-wrap: break-word; word-break: break-all, the table does not support width, but the content is not completely displayed. It only displays the content with the same width as the table. Other content is blocked or filtered out. I have Chinese characters. Does it matter? Is there any way to change the number of words in the table automatically? Or you can wrap a line without a large table, and skip the content! My content is called in the ease of operation! The content I added when creating a webpage is always wide and ugly after the webpage is generated. I added style = "table-layout: fixed; word-wrap: break-word; word-break: break-all "after the code, the table will not be wide, but the content is not completely displayed, only the content with the same width of the table is displayed. Other content is blocked or filtered out. I have Chinese characters. Does it matter? Is there any way to change the number of words in the table automatically? Or you can wrap a line without a large table, and skip the content! My content is called in the ease of operation! </Body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Related Article

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.