Line break not working

Discussion in 'JavaScript' started by nmretd, Jun 4, 2007.

  1. #1
    I am using the \n in the sProfile1 string variable but it does not work. Can someone help me with this ?

    Thanks.

    var sProfile1 = "test\nstring";

    function showPic (whichpic)
    {
    if (document.getElementById)
    {
    document.getElementById('placeholder').src = whichpic.href;
    if (whichpic.title)
    {
    if (whichpic.id==1)
    {
    document.getElementById('desc').childNodes[0].nodeValue = sProfile1;
    }
    }
    }
    }
     
    nmretd, Jun 4, 2007 IP
  2. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Please use the code tags when posting code. It's the # on the toolbar.

    Use "<br>" and innerHTML:

    
    varsProfile1  = "test<br>string";
    
    document.getElementById('desc').innerHTML = Profile1;
    
    Code (markup):
     
    Mike H., Jun 4, 2007 IP