你如何向 JQuery 弹出窗口添加换行符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14113476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 13:16:56  来源:igfitidea点击:

How do you add line break to JQuery popover

jquerytwitter-bootstrap

提问by Boundless

How can I add a line break in my popover content? Neither the line break tag, nor the new line character is working. This is what I'm trying:

如何在弹出框内容中添加换行符?换行标记和换行符都不起作用。这就是我正在尝试的:

$(".foo").hover(function () {
    $(this).popover({
        title: "Bar",
        content: "Line 1 <br /> Line 2 \n Line 3"

    }).popover('show');
}, function () {
    $(this).popover('hide');
});

回答by antinome

You need to pass the option html: truewhen you initialize the popover. Then <br />and other html tags should work:

您需要html: true在初始化弹出窗口时传递该选项。然后<br />和其他 html 标签应该可以工作:

$(".foo").hover(function () {
    $(this).popover({
        title: "Bar",
        content: "Line 1 <br /> Line 2 <br /> Line 3",
        html: true
    }).popover('show');
}, function () {
    $(this).popover('hide');
});

https://groups.google.com/forum/?fromgroups=#!topic/twitter-bootstrap/bhtpERLYCo4

https://groups.google.com/forum/?fromgroups=#!topic/twitter-bootstrap/bhtpERLYCo4