Jquery: How hide or close all open bootstrap tooltip

前端 未结 5 1811
温柔的废话
温柔的废话 2021-02-20 08:42

This way I am showing bootstrap tooltip from my validation function.

var options = { html: true, placement: \'bottom\', title: \'
相关标签:
5条回答
  • 2021-02-20 09:04

    When you have 100s of tooltips open, I believe you have given .tooltip class for everything. So, you can use this shorthand to close all the tooltips:

    $(".tooltip").tooltip("hide");
    

    Snippet

    $(function () {
      $('[data-toggle="tooltip"], .tooltip').tooltip();
      $('[data-toggle="tooltip"], .tooltip').tooltip("show");
      $("button").click(function () {
        $('[data-toggle="tooltip"], .tooltip').tooltip("hide");
      });
    });
    body {padding: 50px;}
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>
    <a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>
    <a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>
    <br /><br />
    <button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</button>
    
    <button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Tooltip on top">Tooltip on top</button>
    
    <button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">Tooltip on bottom</button>
    
    <button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="right" title="Tooltip on right">Tooltip on right</button>
    
    <br />
    <br /><br /><br />
    <button>Hide All</button>

    0 讨论(0)
  • 2021-02-20 09:11

    i have done the job this way....just iterate in table.

    function HideToolTips() {
        $('#StudentGrid tbody > tr').each(function (i, row) {
                $(this).find("input[id*='FirstName']").tooltip('hide');
                $(this).find("input[id*='LastName']").tooltip('hide');
                $(this).find("select[id*='cboState'] :selected").tooltip('hide');
                $(this).find("select[id*='cboCity'] :selected").tooltip('hide');
        });
    }
    
    0 讨论(0)
  • 2021-02-20 09:15

    Use the below code for hiding all tooltips.

    $('[data-toggle="tooltip"]').tooltip('hide');
    

    -Help :)

    0 讨论(0)
  • 2021-02-20 09:23

    this will help close tooltip at any button, any id

    $(document).on("click","button",function(){$(this).trigger("blur")})
    $(document).on("mouseup","button",function(){$(this).trigger("blur")})
    $(document).on("mousedown","button",function(){$(this).trigger("blur")})
    

    Tooltip will close button's tooltip on button click

    0 讨论(0)
  • 2021-02-20 09:25

    My sollution is

    $(".ui-tooltip").css('display','none');
    
    0 讨论(0)
提交回复
热议问题