Reputation: 423
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>
Upvotes: 1
Views: 58
Reputation: 754
Change .text to .html
$('#Msg').html('line1<br>line2');
OR
var escaped = $('<div>').text(stringDisplay).text();
$('#Msg').html(escaped.replace(/\n/g, '<br />'));
Upvotes: 0
Reputation: 17614
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
Upvotes: 1
Reputation: 318202
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()
Upvotes: 3