如何为JQuery popover添加换行符

Bou*_*ess 13 jquery twitter-bootstrap

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

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

    }).popover('show');
}, function () {
    $(this).popover('hide');
});
Run Code Online (Sandbox Code Playgroud)

ant*_*ome 48

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');
});
Run Code Online (Sandbox Code Playgroud)

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

  • 您还可以将其设置为标记中的数据属性,如下所示:data-html ="true" (7认同)