Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Placement of Bootstrap Tooltips via JavaScript</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script> <style> .bs-example{ margin: 100px 60px; } </style> <script> document.addEventListener("DOMContentLoaded", function(){ // Placement of tooltip on top var tipTop = document.getElementById("tipTop"); var tooltipTop = new bootstrap.Tooltip(tipTop, { placement : "top" }); // Placement of tooltip on right var tipRight = document.getElementById("tipRight"); var tooltipRight = new bootstrap.Tooltip(tipRight, { placement : "right" }); // Placement of tooltip on bottom var tipBottom = document.getElementById("tipBottom"); var tooltipBottom = new bootstrap.Tooltip(tipBottom, { placement : "bottom" }); // Placement of tooltip on left var tipLeft = document.getElementById("tipLeft"); var tooltipLeft = new bootstrap.Tooltip(tipLeft, { placement : "left" }); }); </script> </head> <body> <div class="bs-example"> <ul class="list-inline"> <li class="list-inline-item"> <a href="#" id="tipTop" data-bs-toggle="tooltip" title="Tooltip on top">Tooltip on top</a> </li> <li class="list-inline-item"> <a href="#" id="tipRight" data-bs-toggle="tooltip" title="Tooltip on right">Tooltip on right</a> </li> <li class="list-inline-item"> <a href="#" id="tipBottom" data-bs-toggle="tooltip" title="Tooltip on bottom">Tooltip on bottom</a> </li> <li class="list-inline-item"> <a href="#" id="tipLeft" data-bs-toggle="tooltip" title="Tooltip on left">Tooltip on left</a> </li> </ul> </div> </body> </html>