Toggling Bootstrap Tooltip divs within a nested structure triggers the Tooltip of the parent div

  • I have a setup with 2 nested <div> elements, both utilizing the tooltip() function.
  • When I hover over the inner <div>, the tooltip of the outer <div> also displays.
  • To resolve this issue, I attempted to clear the title of the inner <div> on :hover.
$(inner).hover({
  $(outer).attr('title', '');
}, {
  $(outer).attr('title', 'original title');
});

A functioning example is available in my CodePen demo. Note that I changed the title to 'red' for visibility.

  1. Why doesn't changing the title alter the tooltip's content?
  2. What is the process for modifying the Bootstrap Tooltip's content? (This could be its own standalone question on Stack Overflow)

Answer №1

Response to query #1:

Upon thorough examination of the components and observing their behavior with your JavaScript code, I have discovered an attribute within the divs labeled as data-original-title. It appears that even when changed to green, this attribute continues to retain "blue," which is what the tooltip element interprets and shows. To address this issue, you can modify your script as follows:

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

Executing this adjustment transforms the color from blue to red. Do you find this solution satisfactory?

Answer №2

To make the tooltip hide and show, you can use .tooltip('hide') and .tooltip('show').
Credit to @BuddhistBeast for providing part of this answer!

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

Answer №3

Find out if you are currently hovering inside the inner block

Using jQuery:

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

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


  $("#a").on('mousemove', function(){  
    if(isHovering) {
      $(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 Customized Example: http://codepen.io/anon/pen/JGqXPw

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with slideout menu hyperlinks malfunctioning

Currently developing a site at , everything seemed ready for deployment until testing in 320x480 mode on mobile revealed that the links on the slideout menu were not working on any mobile device I tried, regardless of resolution or page. I've tried u ...

Various hues blending and intertwining with one another

https://i.stack.imgur.com/zLrNK.png Could someone please clarify what is happening here? I'm attempting to change the background color to dodgerblue, but for some reason, the white background color is still showing through. Below is the code snippet ...

Responsive navigation menus can create confusion when hover and click events overlap

Check out my HTML5 responsive, 2-level menu by clicking HERE. The menu displays submenus on hover for wide screens and on click for narrow screens (less than 768px). The JavaScript function responsible for switching the events is shown below: function ho ...

The functionality of Bootstrap tooltips becomes disabled as soon as any element on the page is clicked

When initializing Bootstrap tooltips on my page, I follow this approach <script> $(document).ready(function () { $(function () { $('[data-toggle="tooltip"]').tooltip(); }); }); </script> A questio ...

Enhancing this testimonial slider with captivating animations

I have designed a testimonial slider with CSS3 and now I am looking to enhance it by adding some animation using Jquery. However, I am not sure how to integrate Jquery with this slider or which plugins would work best for this purpose. Can anyone provide g ...

Place a vertical slider adjacent to an HTML element on either the left or right side

I'm struggling to bind a range slider to the left or right side of a canvas that displays video. Despite my efforts, CSS seems to be putting up a strong fight. I can handle issues like stretching and slider values, but attaching it to the canvas is pr ...

Tips for retrieving the primary key of the highlighted row in bs_grid

I've integrated bs_grid to showcase a lineup of company names, each associated with a unique GUID identifier. Here's how I've set up the grid: $(function() { $('#grid1').bs_grid({ ajaxFetchDataURL: 'CompaniesList.asmx/G ...

The art of arranging React components

I'm struggling to organize my react components properly and I'm having difficulty with CSS Flexbox. Here are the 3 react components: function App() { return ( <> <div className = "header"> <h1>Connect ...

Setting up a textarea tooltip using highlighter.js

I'm experimenting with using highlighter.js within a textarea. I've customized their sample by substituting the p with a textarea enclosed in a pre tag (for right-to-left language settings). <div class="article" style="width: 80%; height: 80% ...

Struggling to grasp the concept of using z-index in CSS

As a programmer versed in Python, C, Java, and Delphi, I am not a web developer or designer by trade. However, when required to fill those roles, I do my best; please be patient with me. :-) I have created a map (with a background image as a div), where I ...

What is the best way to incorporate an icon into my HTML search bar?

I'm having trouble getting the search icon from font awesome to display properly within my search bar. Here is the code I'm using: <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" rel="stylesheet"/> ...

What adjustments can be made to the Bootstrap code to prevent it from causing layout issues with the Signin Form and Footer?

Recently, I've encountered some challenges with the footer formatting on my website's home page and the sign-in form on a separate page. It appears that the Bootstrap framework at the top of the page is affecting these elements exclusively. How c ...

jQuery Autocomplete API Issue: Undefined

I've been attempting to implement a basic text box using the jQuery API from DevBridge. I followed instructions in this video tutorial to create my code. However, despite properly declaring scripts before the JS code and ensuring proper mappings, I&a ...

Is it possible to maintain the width of an element even when its height is set to 0px?

Let me provide a detailed explanation of my issue below, but the question remains the same: Is there a way to make an element hidden or invisible with a height of 0px or slightly more than 0px while maintaining its width for functionality in Safari? Here ...

Troubleshooting HTML/CSS and JavaScript Issues with Dropdown Menus

I'm having trouble getting my dropdown menu to work properly and I can't figure out why. The JavaScript code should toggle a class that hides the language options and slides up the other tabs like "Contact". However, when I click the button, noth ...

Having trouble with Tailwind CSS not functioning correctly once the font is imported?

I am currently working on a next.js project and utilizing tailwind for styling. I have noticed an odd behavior when importing a custom font into my globals.css file. page.jsx "use client"; import React from "react"; const page = () = ...

The hamburger menu on the responsive navbar fails to open when clicked on

Having an issue with my navbar in mobile and responsive environments. The hamburger menu shows up, but when clicked on, the links are not displayed. Below is the code that I am using, all the necessary links are included but the menu is not functioning pro ...

Having trouble getting the align-items-end property in Bootstrap 4 to function

After dedicating almost two full weeks to this project, I'm still struggling to achieve the desired outcome. I suspect that the issue may lie in the depth of the rows and columns I'm working with, but I'm open to any external perspectives or ...

Combining the p class with flexbox for optimal layout design

I have four flexed container boxes and I am looking to add text below them in a row. Does anyone have suggestions on how I can achieve this alignment, as well as tips for optimizing the code? .container { display: flex; flex-direction: row; just ...

"Opt for a horizontal WordPress drop-down menu instead of the typical vertical layout

I am looking to customize a menu in WordPress by creating a horizontal drop-down menu instead of the default vertical layout. An example of what I am aiming for can be seen on this website. If you hover over OUR SECTORS, you will see the type of menu I am ...