【问题标题】:bootstrap - how to display dynamic div inside popoverbootstrap - 如何在弹出框内显示动态 div
【发布时间】:2015-01-07 07:26:46
【问题描述】:

我正在使用 Twitter bootstrap 3 并有一个关于 popover 的问题。我的页面中有许多带有“详细信息”类的按钮,我想为这些按钮使用弹出框。但 每个按钮的弹出框内容必须不同。为此,我有一个

<div class="details-box" style="display: none;">
   <h1>Dynamic content</h1>
</div>

每个按钮。注意这些 div 的内容是动态的并且来自我的服务器。现在我的问题是:如何在弹出框内使用这些 div?

【问题讨论】:

    标签: jquery html twitter-bootstrap popover


    【解决方案1】:

    对于每个按钮,使用text() 函数获取h1 中的文本并将其分配给data-content 属性

    查看demo

    var box = $('.details-box');
    box.each(function() {
        var that = $(this);
        var text = that.text();
        that.attr('data-content', text);
        that.popover();
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-27
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      • 2012-06-25
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      相关资源
      最近更新 更多