1

nowadays i am upto java script, jquery etc. i am facing little problem.

i am writing a text message inside CASE block , it's a long string when displayed:

Record has been saved successfully Note: If head already exists for the concerned department than your head selection would not have been saved. 

but i want it like this:

Record has been saved successfully Note: If head already exists for selected department than your head selected would not have been saved. function ShowMsg() { var MessageStatus = $("#HiddenFieldSetMessage").val(); switch (MessageStatus) { case 'SavedButHeadMightExist': $("#Msg").text("Record has been saved successfully Note: If head already exists for the concerned department than your head selection would not have been saved"); $("#ModalHeader").text("Success"); break; case 'NotSaved': $("#Msg").text("Record not inserted"); $("#ModalHeader").text("Error"); break; } </script> 

3 Answers 3

3

You could use newlines, but those aren't really shown, what you really want is probably just break tags

$("#Msg").html("Record has been saved successfully<br />" + "Note: If head already exists for the concerned department<br />" + "than your head selection would not have been saved"); 

Note that you have to change the method from text() to html()

Sign up to request clarification or add additional context in comments.

Comments

1

you need to use <br/> for line break. and use html instead of text

text: it is used for text only no html is allowed
html: it allow html tags also

You can find difference between these two here

  1. What is the difference between jQuery: text() and html() ?

Comments

0

Change .text to .html

$('#Msg').html('line1<br>line2'); 

OR

var escaped = $('<div>').text(stringDisplay).text(); $('#Msg').html(escaped.replace(/\n/g, '<br />')); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.