jquery - bootstrap 2.3.2 popover html 内容问题

标签 jquery html css twitter-bootstrap twitter-bootstrap-2

我正在尝试填充 popover动态地通过

JavaScript

$("[data-bind='popover']").popover({
 trigger: 'hover',
 html: true,
 content: function(){ 
  return "<img src="+$(this).data('content')+" />";
 };
});

HTML

<a href="myreference.html" data-bind="popover" data-content="mylinktoimage">Brick</a> 

问题是如果我设置 widthheightimg里面tag里面js , popover出现。如果我不设置它们,首先是 anchor <a> pointer cursor “振动”和 popover未显示。

这会是什么问题?

最佳答案

你确定上面的代码真的有效吗?甚至不能让弹出窗口工作,例如

..
return "<img src="+$(this).data('content')+" />;
 });

??认为那是你的问题。

<a href="myreference.html" data-bind="popover" data-content="flower.jpg">Brick</a> 

更新,也适用于外部在线图片

<a href="myreference.html" data-bind="popover" data-content="http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Flower_poster_2.jpg/451px-Flower_poster_2.jpg">Brick</a> 

$("[data-bind='popover']").popover({
   trigger: 'hover',
   html: true,
   content: function(){ 
      return '<img src="'+$(this).data('content')+'">';
   }
});

产生:

enter image description here

$("[data-bind='popover']").popover({
   trigger: 'hover',
   html: true,
   content: function(){ 
      return '<img src="'+$(this).data('content')+'" width="50">';
   }
});

产生

enter image description here

没有“振动”等

关于jquery - bootstrap 2.3.2 popover html 内容问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18853263/

相关文章:

javascript - FullPage.js - slider 每次自动滚动到顶部

javascript - 使用 CSS 或 javascript 在 html 4 中折叠和展开列表的最佳方法是什么

mobile - 移动浏览器的工具提示

css - React-bootstrap SCSS 主题 orerride 不起作用

html - 在 CSS flexbox 的粘性页眉和页脚中仅滚动子标题下的中间内容

javascript - 检测到输入文件控件中未选择文件

jquery - 如何在鼠标悬停时获取 "pop-up"术语引用中的超链接,并将 HTML 术语与 "pop-up"引用内容分开

javascript - 有没有办法将参数传递给在 jQuery .click 上调用的函数?

JavaScript 不会在鼠标悬停时运行

HTML/CSS 标题图像有边距,我看不出任何原因