Bootstrap .popover(“ show”)方法

使用popver(“ show”)方法显示弹出窗口。

您需要将弹出窗口设置为-

<a href="#" data-toggle="popover" title="Demo Header" data-content="这是演示文字!">
  Sample
</a>

现在显示弹出窗口-

$(document).ready(function(){
  $(".btn-default").click(function(){
    $("[data-toggle='popover']").popover('show');
  });
});

让我们看完整的示例显示如何实现popover(“ show”)方法-

示例

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>

<body>

  <div class="container">
    <h3>Demo</h3>
    <a href="#" data-toggle="popover" title="Demo Header" data-content="这是演示文字!">Sample</a>
    <div>
      <p>The following is a demo button:</p>
      <button type="button" class="btn btn-default">Demo Button</button>
    </div>  
  </div>

<script>
  $(document).ready(function(){
    $(".btn-default").click(function(){
      $("[data-toggle='popover']").popover('show');
    });
   });
</script>

</body>
</html>