切换布局
显示结果
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap4 使用JavaScript启用工具提示 - 迹忆客(jiyik.com)</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script> <style> .bs-example{ margin: 100px 60px; } </style> <script> $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); }); </script> </head> <body> <div class="mt-3 mx-5"> <h2>Tooltips on Links</h2> <div class="bs-example"> <a href="#" data-bs-toggle="tooltip" title="Default tooltip">Tooltip</a> <a href="#" data-bs-toggle="tooltip" title="Another tooltip">Another tooltip</a> <a href="#" data-bs-toggle="tooltip" title="A much longer tooltip to demonstrate the max-width of the Bootstrap tooltip.">Large tooltip</a> <a href="#" data-bs-toggle="tooltip" title="The last tip!">Last tooltip</a> </div> <h2>Tooltips on Buttons</h2> <div class="bs-example"> <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" title="Default tooltip">Tooltip</button> <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" title="Another tooltip">Another tooltip</button> <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" title="A much longer tooltip to demonstrate the max-width of the Bootstrap tooltip.">Large tooltip</button> <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" title="The last tip!">Last tooltip</button> </div> <h2>Tooltips on Icons</h2> <div class="bs-example"> <a href="#" data-bs-toggle="tooltip" title="Edit"><i class="bi-pencil-fill"></i></a> <a href="#" data-bs-toggle="tooltip" title="Save"><i class="bi-save-fill"></i></a> <a href="#" data-bs-toggle="tooltip" title="Print"><i class="bi-printer-fill"></i></a> <a href="#" data-bs-toggle="tooltip" title="Delete"><i class="bi-trash"></i></a> <a href="#" data-bs-toggle="tooltip" title="Settings"><i class="bi-gear-fill"></i></a> </div> </div> </body> </html>