所以我有一个图标列表,当你将鼠标悬停在图标上时,我试图让弹出窗口激活,我似乎无法让它工作,任何帮助都将不胜感激。
<img class="icon" rel="popover" trigger: "hover" data-placement="top" data content="This is a popover"src="images/brandable.png"><br>Brandable</br></li>我把它放在一个单独的js文件中。
$('.icon').popover({placement:'top'});发布于 2014-07-23 21:26:25
这已经晚了一年多了,但是我发现这个是有效的:Fiddler Link
使用这个JS:
$(function(){
$('[data-toggle=popover]').popover({
trigger: 'focus',
html: true,
title: 'Toolbox'
})
});和这个html:
<img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcS-eTmHxgicEfq4K-sEz_X52cq56uBP2l8cr_q8ivOavSIca5TYtQ"
data-toggle="popover" tabindex="50" data-content="test <b>text</b>" data-placement="right"/>您需要允许图像使用tabindex属性接受焦点。这对我来说是关键。如果您希望在单击事件时保持弹出窗口的打开状态,请删除"trigger:'focus‘行...
希望它能帮上忙!
发布于 2016-01-28 16:35:40
将属性放在jquery变量中,而不是标签中
<img class="icon" rel="popover" src="images/brandable.png"/>按如下方式添加脚本
<script>
$('document').ready(function() {
var popOverSettings = {
placement: 'top',
selector: '.icon',
title:'Brandable',
trigger: "hover",
content:'This is a popover'
};
$(this).popover(popOverSettings);
});
</script>发布于 2013-11-07 11:35:08
对于你的代码,你有:
<img class="icon" rel="popover" trigger: "hover" data-placement="top" data content="This is a popover"src="images/brandable.png"><br>Brandable</br></li>trigger: "hover"不是有效的html。Bootstrap帮助文档备注:“选项可以通过数据属性或JavaScript传递。对于数据属性,请将选项名称附加到数据-,如在data-animation=""中。”
因此,相反,您可能希望包含data-trigger="hover“,而且看起来在src=之前缺少一个空格。
另外,在html和javascript中也有位置top。你只需要在一个地方声明。因此,您可以从img标记中删除data-placement="top“,或者在javascript中删除它,这样它就变成了$('.icon').popover({placement:'top'});
在你的函数前面也有"$“。根据代码所在的位置,您可能会遇到jquery冲突。为了确认,您需要发布在错误日志中看到的任何错误。如果您使用chrome,右键单击> web inspect >单击底部的红色x,然后复制您在那里看到的任何错误。
https://stackoverflow.com/questions/14760006
复制相似问题