You must Sign In to post a response.
  • Category: JavaScript

    to print a new line in javascript

    how to print a value in new line in JavaScript, when all the values are stored in a single variable or string


    Pls help me its urgent

    Regards,
    Divakarand
  • #302138
    Hi divakaran,

    if u want to give new line in javascript the code as follows:
    <script language="javascript">
    document.writeln("Hello");
    document.write("Hi");
    </script>

    or use break tag <br> in the document.write("Hello <br>");

    try both the things then u will solve that issue.

    all the best

  • #302457
    Hi,

    refer the following code:
    <script type="text/javascript">
    var var1 = new Array();
    var1[0] = "aaa";
    var1[1] = "bbb";
    var1[2] = "ccc";
    for (i=0;i<var1.length;i++)
    {
    document.write(var1[i] + "<br />");
    }
    </script>

    output:
    aaa
    bbb
    ccc

    Hope this helps you!
    Happy programming!

    Regards,
    Vidhya

    Note:
    Kindly rate this content if it really helps you!


This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.