1

我尝试使用这个

html

<div class="company-logo">
    <a class="popup" href="#" data-toggle="popover" data-content="Download den Mazda Case (.pdf)">
        <img src="img/logo/mazda.png" alt="logo">
    </a>
</div>

JS

$(function () {
    var pop_description = $(this).attr("data-content");
    var pop_link = $(this).attr("href");
    var pop_content = '<a href="' + pop_link + '">' + pop_description + '</a>';


    $('.popup').popover({
        placement: 'top',
        html: true,
        content: pop_description
    });

});

但这是错误的,我有未定义的。我想在弹出框内容中添加链接

4

2 回答 2

1

您可以创建一个名为“my-popover”的自定义弹出框

HTML

<div class="company-logo">
    <a class="popup" href="#" data-toggle="my-popover" data-content="Download den Mazda Case (.pdf)">
        <img src="img/logo/mazda.png" alt="logo">
    </a>
</div>

JS

$('[data-toggle="my-popover"]').popover({
        'placement': 'top',
        'template':'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div><a href="' + pop_link + '"><div class="popover-content"></div></a></div></div>',
        'html': 'true'
  });
于 2015-04-01T23:35:37.730 回答
0

你为什么不试试这个?

$(function () {
    var pop_description = $(this).attr("data-content");
    var pop_link = $(this).attr('href','http://example.com');
    var pop_content = '<a href="' + pop_link + '">' + pop_description + '</a>';
alert(pop_content);

    $('.popup').popover({
        placement: 'top',
        html: true,
       // content: pop_description
    });

});

我希望我能得到你想要做什么?

于 2013-03-06T09:38:17.450 回答