7

这是我的 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 错误或任何东西,不知道出了什么问题

4

2 回答 2

9

使用您的确切代码,我所要做的就是将它包装在一个函数调用中并将脚本放在 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'
  });
});
于 2013-07-06T03:54:02.780 回答
1

我一直在寻找一天多的时间,为什么我的弹出框在由于我的页面上发生的事件而被自动禁用后无法工作(一个复杂的应用程序,根据正在发生的状态启用/禁用的东西)和关键是不要让它准备好文档,而是将它放在一个函数中,因为它在单击按钮后初始化文档后启用。

于 2015-03-07T21:12:17.617 回答