HTML textarea: use JavaScript to get wrapped text?

前端 未结 5 1606
伪装坚强ぢ
伪装坚强ぢ 2021-01-03 15:31

If I\'ve got a textarea like this:


Is there any way, using JavaScript, t

5条回答
  •  春和景丽
    2021-01-03 16:28

    I don't think it's possible out of the box You could wrap the text yourself using textarea's cols value. From the HTML point of view the text in textarea is not wrapped. It's just how it's being displayed for you to be able to read it better.

    PS. If you are using jQuery you should use $('#foo') instead of $('[id=foo]') selector as it's much faster (and shorter).

提交回复
热议问题