Articles → BOOTSTRAP → Tooltip In Bootstrap
Tooltip In Bootstrap
Steps Of Tooltip Implementation
- Add a "data-toggle" attribute inside the element where you want to show tooltip.
- Add a "title" attribute to specify the text of the tooltip.
- Add a "data-placement" attribute to specify the position of the tooltip.
- Call the tooltip method in jQuery.
Example
<!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.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<span data-toggle="span-tooltip" title="This is the sample span tooltip" data-placement="bottom">Welcome to the tooltip example</span>
</div>
<script>
$(document).ready(function () {
$('[data-toggle="span-tooltip"]').tooltip();
});
</script>
</body>
</html>
Output
Click to Enlarge
Tooltip Position
- top
- bottom
- right
- left
- auto