wrapping text words in new line

后端 未结 8 727
眼角桃花
眼角桃花 2021-02-10 04:53

I\'m using the below code for wrapping long text, entered by users in a text area for commenting:

function addNewlines(comments) {
  var result = \'\';
  while (         


        
8条回答
  •  北荒
    北荒 (楼主)
    2021-02-10 05:28

    Try word-wrap: break-word in CSS.
    The word-wrap property is well supported by browsers (even IE 5.5+).
    More info here: https://developer.mozilla.org/en-US/docs/CSS/word-wrap
    Sample usage: FIDDLE

提交回复
热议问题