应用Popover消息框OnClick

时间:2017-03-30 22:29:49

标签: javascript jquery html css twitter-bootstrap

我对此很陌生。我在下面的链接中找到了一个popover消息框的示例。我试图实现它,它似乎工作,我错过了什么?

或者是他们更容易实现一个看起来像图像中的on的弹出框消息框(onclick)。

链接:http://getbootstrap.com/javascript/#js-individual-compiled

图片:enter image description here



<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>



<button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="left" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Popover on left
</button>

<button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="top" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Popover on top
</button>

<button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom" data-content="Vivamus
sagittis lacus vel augue laoreet rutrum faucibus.">
  Popover on bottom
</button>

<button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="right" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Popover on right
</button>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

弹出窗口功能在Bootstrap中是可选的。您需要通过添加以下代码来启用它:

<script>
$(function () {
  $('[data-toggle="popover"]').popover()
})
</script>