且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Bootstrap工具提示-单击另一个工具提示时隐藏

更新时间:2023-08-16 23:13:52

您需要检查工具提示是否显示并手动切换其可见性.这是一种方法.

You need to check if the tooltip is showing and toggle its visibility manually. This is one way of doing it.

$(function() {
  var HasTooltip = $('.hastooltip');
  HasTooltip.on('click', function(e) {
    e.preventDefault();
    var isShowing = $(this).data('isShowing');
    HasTooltip.removeData('isShowing');
    if (isShowing !== 'true')
    {
      HasTooltip.not(this).tooltip('hide');
      $(this).data('isShowing', "true");
      $(this).tooltip('show');
    }
    else
    {
      $(this).tooltip('hide');
    }

  }).tooltip({
    animation: true,
    trigger: 'manual'
  });
});