I have a span like this :
<span class "message"></span>
And I am filling it from javascript like this :
message = "first message" + "\\\n";
message = message + "second message";
$(".message".)text(errorMessage);
$(".message").show();
The problem with that, is when the text is displayed on my browser, the 2 messages are on the same line, I can't insert the second with a newline. Whereas in my debug console, the text appears well on 2 lines. I have also tried the <br>
, which is worst as it's not interpreted, so I am getting a message like this :
first message br second message.
Basically, I would like to have displayed :
first message
second message
You can use
<br />
andhtml()
to break the text on new line:Docs: http://api.jquery.com/html/