Bootstrap .tooltip(options) 方法


在 Bootstrap 中使用 tooltip(“options”) 方法來啟用工具提示。

將游標保持在下方的按鈕上,可顯示工具提示 −

<button class="btn btn-default btn-lg">
  Keep cursor
</button>

以下是使用 tooltip(options) 類生成的工具提示指令碼 −

$(document).ready(function(){
  $('.btn-default').tooltip({title: "demo", placement: "top"});
});

你可以嘗試執行以下程式碼來實現 tooltip(“options”) 方法 −

示例

即時演示

<!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://ajax.googleapis.com/ajax/libs/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>Example</h3>
    <p>Tootltip will be visible after you mouse hover the below button:</p>
    <div>
      <button class="btn btn-default btn-lg">Keep cursor</button>
    </div>
  </div>

  <script>  
  $(document).ready(function(){
    $('.btn-default').tooltip({title: "demo", placement: "top"});
  });
  </script>

</body>
</html>

更新於: 2020年6月18日

859 次瀏覽

開啟你的 職業生涯

透過完成課程進行認證

開始
廣告
© . All rights reserved.