0
  • I have 2 nested <div>s, both with tooltip().
  • When I hover over the inner <div>, the outer <div> also shows it's tooltip.
  • I tried to work around this by setting the inner <div>'s title to an empty string on :hover.
$(inner).hover({
  $(outer).attr('title','');
},{
  $(outer).attr('title','original title');
});

I created a codepen example

note: I changed title to 'red' so you can see that the title did indeed change.

  1. Why is it that changing the title doesn't change tooltip's content?
  2. How do we change the Bootstrap Tooltip's content? (this should be a stackoverflow question of it's own)
warkentien2
  • 969
  • 13
  • 20

3 Answers3

1

Answering #1:

By inspecting the elements and watching it change with your JS code, i noticed a attribute on the divs called data-original-title which still holds "blue" when you enter green (this is what the tooltip element reads and displays). By changing your script to

 $('#a').attr({"data-original-title": "red"});

the blue becomes red. Does this answer your question?

Mindbender
  • 81
  • 1
  • 6
0

You can check whether you are currently hovering inside of the inner block

jQuery:

$(document).ready(function(){
  var bIsShown = true;
  $("#b").on('mouseenter', function(){  
      bIsShown = true;

  }).on('mouseleave', function() {
      bIsShown = false;
  })


  $("#a").on('mousemove', function(){  
    if(bIsShown) {
      $(this).data("bs.tooltip").$tip.removeClass("in");
    }
    else {
      $(this).data("bs.tooltip").$tip.addClass("in");
    }
  })
  $('[data-toggle="tooltip"]').tooltip({
    animated : 'fade',
    placement : 'bottom',
    container: 'body'});
});

Your Example: http://codepen.io/anon/pen/JGqXPw

BuddhistBeast
  • 2,652
  • 2
  • 21
  • 29
0

Use .tooltip('hide') and .tooltip('show')
this was answered in part by @BuddhistBeast, thanks!

$("#b").on('mouseover', function(){   
    $('#a').tooltip('hide');
  }).on('mouseleave', function(){   
    $('#a').tooltip('show');
  });
  $('[data-toggle="tooltip"]').tooltip({
    animated : 'true',
    placement : 'bottom',
    container: 'body'});
warkentien2
  • 969
  • 13
  • 20