这是我的 HTML:
<div id="disclaimer">After 30 Days you'll have the option to keep your account for $15 per month -no contract required-or revert to a single page free account.*</div>
JavaScript:
$('#disclaimer').popover({
trigger: 'hover',
html: true,
placement: 'right',
content: 'hello world'
});
当我将鼠标悬停在元素上时,什么都没有发生.. 没有 JavaScript 错误或任何东西,不知道出了什么问题
最佳答案
使用您的确切代码,我所要做的就是将它包装在一个函数调用中并将脚本放在 div 标签下面。如果您将 jQuery 放在 onload 函数中,它也可以正常工作。祝你好运。
用这个:
<div id="disclaimer" >After 30 Days you'll have the option to keep your account for $15 per month -no contract required-or revert to a single page free account.*</div>
<script>
$(function ()
{
$('#disclaimer').popover(
{
trigger: 'hover',
html: true,
placement: 'right',
content: 'hello world'
});
});
</script>
或者
$(document).ready(function()
{
$('#disclaimer').popover(
{
trigger: 'hover',
html: true,
placement: 'right',
content: 'hello world'
});
});
关于twitter-bootstrap - Twitter Bootstrap Popovers 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17499438/