如何制作bootstrap popover内容取决于点击按钮

时间:2014-02-17 13:21:36

标签: javascript jquery html twitter-bootstrap

我想显示一个包含有关所点击锚点信息的引导程序弹出窗口。锚是动态添加的。这是锚码 html ::

<a id='reserveAnchorClone' offsetx="0.4882005899705015" offsety="0.41685144124168516" data-container="body" rel='popover'  data-placement="left" class="reserveAnchor"  >37</a>

JS ::

  var popOverSettings = {
        placement: 'left' ,
        container: 'body',
        html: true,
        selector: '.reserveAnchor',
        content: function(){return $('#popover_content_wrapper_add').html();},
    }
$('body').popover(popOverSettings);

我想在popover中显示anchor的offsetX offsetY属性,我该怎么做呢。

1 个答案:

答案 0 :(得分:0)

每当您动态添加锚点时,只需添加以下内容:

var popOverSettings = {
    tite: $('#reserveAnchorClone').attr('id'),
        content: function(){return $('#reserveAnchorClone').attr('offsetx') + "<br/>" + $('#reserveAnchorClone').attr('offsety');},
    }
$('#reserveAnchorClone').popover(popOverSettings);

http://jsfiddle.net/e3g4h/3/