如何为JQuery popover添加换行符

时间:2013-01-01 19:24:27

标签: 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');
});

1 个答案:

答案 0 :(得分: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');
});

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

相关问题