Articles → BOOTSTRAP → Tooltip In Bootstrap

Tooltip In Bootstrap






Steps Of Tooltip Implementation




  1. Add a "data-toggle" attribute inside the element where you want to show tooltip.
  2. Add a "title" attribute to specify the text of the tooltip.
  3. Add a "data-placement" attribute to specify the position of the tooltip.
  4. 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


Picture showing the output of tooltip in bootstrap
Click to Enlarge


Tooltip Position




  1. top
  2. bottom
  3. right
  4. left
  5. auto





Posted By  -  Karan Gupta
 
Posted On  -  Sunday, November 21, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250