locked
how to add line break to a var string in JS RRS feed

  • Question

  • User-775831949 posted

    I have this JS and the alert gives the result in several lines based on "\n" as desired

    alert(selected1 + "\n" + selected2);

    Now I change to use model instead of

     var modalMsg = selected1 + "\n" + selected2 ;
     $('.modal-body').text(modalMsg);

    There is no line break between selected 1 and selected2 when displaying, pls help what do I need to do to display the line break.

    Thanks

    Thursday, October 12, 2017 6:09 AM

Answers

  • User-775831949 posted

    I changed text into html then it works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 12, 2017 11:09 AM

All replies

  • User-775831949 posted

    I changed text into html then it works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 12, 2017 11:09 AM
  • User-1838255255 posted

    Hi hkbeer,

    According to your description and needs, if you want to show break line in alert message, please check the following code:

    Sample Code:

    <script>
            alert("Line 1\nLine 2");
    </script>

    Result:

    Best Regards,

    Eric Du

    Friday, October 13, 2017 2:10 AM