line breaks in a textarea

前端 未结 13 1659
北荒
北荒 2020-11-27 17:58

I know when saving a textarea you can use the nl2br() or str_replace to change the /n to br tags etc. However what im not sure about how to insert line breaks into a textare

13条回答
  •  粉色の甜心
    2020-11-27 18:26

    From PHP using single quotes for the line break worked for me to support the line breaks when I pass that var to an HTML text area value attribute

    PHP

    foreach ($videoUrls as $key => $value) {
      $textAreaValue .= $value->video_url . '\n';
    }
    

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    HTML/JS

    $( document ).ready(function() {
        var text = "";
        document.getElementById("video_urls_textarea").value = text;
    });
    

提交回复
热议问题