Can't change bootstrap Tooltip title

后端 未结 7 1166
傲寒
傲寒 2021-01-12 09:28

I\'ve already looked over several posts on stack overflow asking virtually the exact same question yet none of what I found on those questions has helped. I\'m very new to

相关标签:
7条回答
  • 2021-01-12 10:01

    Change Bootstrap 4 Tooltip title

    $(document).ready(function() {
      // initilizing Tooltip
      $('[data-toggle="tooltip"]').tooltip();
    
      // Get the Tooltip
      let btn_tooltip = $('#my-btn');
    
      // Change Tooltip Text on mouse enter
      btn_tooltip.mouseenter(function () {
        btn_tooltip.attr('title', 'Default Tooltip').tooltip('dispose');
        btn_tooltip.tooltip('show');
      });
    
      // Update Tooltip Text on click
      btn_tooltip.click(function () {
        btn_tooltip.attr('title', 'Modified Tooltip').tooltip('dispose');
        btn_tooltip.tooltip('show');
      });
    });
    <!DOCTYPE html>
    <html lang="en-US">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    </head>
    <body>
    
    <div class="container-fluid">
      <p>Click the button:</p>
      <button id="my-btn" type="button" class="btn btn-primary" data-toggle="tooltip" title="Default tooltip">Click Me</button>
    </div>
    
    </body>
    </html>

    0 讨论(0)
提交回复
热议问题