gpt4 book ai didi

javascript - jquery/javascript 中的换行符

转载 作者:行者123 更新时间:2023-11-30 10:14:33 28 4
gpt4 key购买 nike

现在我正在使用 java 脚本、jquery 等。我面临的问题很小。

我正在 CASE block 中写一条文本消息,显示时它是一个长字符串:

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

但我想要这样:

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>

最佳答案

你可以使用换行符,但这些并没有真正显示出来,你真正想要的可能只是打破标签

$("#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");

请注意,您必须将方法从 text() 更改为 html()

关于javascript - jquery/javascript 中的换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24585273/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com