jquery - Bootstrap popover 出现在与其触发器不同的元素上

标签 jquery html css twitter-bootstrap

我希望弹出窗口出现在另一个元素上而不是触发器上。目前我有:

 $triggerElement.popover({
                title: varTitle,
                content: varContent,
                html: true,
                placement: 'auto top',
                trigger: 'manual'
            });
..........
<div class="shopper"></div> 

<button type="button" class="btn btn-primary">Add</button>

目前弹出窗口正确触发(按钮单击事件)并位于页面底部。但是,我希望将位置设置为 div“购物者”(div 底部)的右上角元素。这可能与选择器有关,还是您可以帮助我使用 CSS。

按钮触发当前在按钮上方绘制的弹出框。但我想将弹出窗口绘制在购物者 div 标签的正下方。因此,购物者 div 标签将成为触发因素。

最佳答案

如果我明白你想要什么,你需要像这样手动显示/隐藏弹出窗口..

$('.shopper').popover({
  title: "varTitle",
  content: "varContent",
  html: true,
  placement: 'bottom',
  trigger: 'manual'
});

$('#trigger').click(function(){
  $('.shopper').popover('toggle');
});

演示:http://www.bootply.com/7oM1aoycIi

关于jquery - Bootstrap popover 出现在与其触发器不同的元素上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36482181/

相关文章:

html - HTML+CSS 中的文本居中,<div> 的一部分在移动,而另一部分没有

jquery - Bootstrap Carousel 过渡元素 + animate.css

javascript - JS - 动态创建的 div 容器包含错误的数据对象

jquery - 在 Underscore 模板中使用 JSON 对象 - Backbone.js

javascript - jQuery Bootstrap Carousel 根据当前幻灯片显示内容

javascript - 如何让图像在滚动时调整大小?

javascript - AngularJS 路由不起作用

javascript - 如果未选中 radio ,则禁用按钮。选中时启用

css - 底部固定图像,如所附截图所示

javascript - 在同一函数中使用 .toggle() 使用 jquery 更改图像