Twitter Bootstrap Popovers无法正常工作

den*_*icz 7 popover twitter-bootstrap

这是我的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>
Run Code Online (Sandbox Code Playgroud)

JavaScript的:

$('#disclaimer').popover({
  trigger: 'hover',
  html: true,
  placement: 'right',
  content: 'hello world'
});
Run Code Online (Sandbox Code Playgroud)

当我将鼠标悬停在元素上时,没有任何反应..没有JavaScript错误或任何东西,不确定是什么错误

Jon*_*han 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>
Run Code Online (Sandbox Code Playgroud)

要么

$(document).ready(function()
{
  $('#disclaimer').popover(
  {
     trigger: 'hover',
     html: true,
     placement: 'right',
     content: 'hello world'
  });
});
Run Code Online (Sandbox Code Playgroud)