0

I have appended a <div> to the body of my page using

$('body').append('<div id="itemInfo"><h2>TEST</h2></div>');

This <div> is hidden in my css. I am then altering the text within the <div> using a function as follows.

    function appendMessage(messagestring) {
    $('#itemInfo h2').text(messagestring);
    $('#itemInfo').fadeIn();
    $('#itemInfo').fadeOut(3000);   
}

This is declared using the following.

appendMessage("Something. ");

The problem is, I cannot seem to get <br /> or /n characters to work within the message. How do I use new line characters within the .text() function?

AMorton1989
  • 313
  • 1
  • 6
  • 30

1 Answers1

5

try use the html() function:

$('#itemInfo h2').html(messagestring);
DZanella
  • 243
  • 1
  • 8