Jquery: How hide or close all open bootstrap tooltip

前端 未结 5 1840
温柔的废话
温柔的废话 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;}
    
    
    
    Hover over me
    Hover over me
    Hover over me
    





提交回复
热议问题