Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

374
Views
How to manage dynamically created bootstrap.Tooltip() with vanilla JS?

Hi I'm working on a multi-page registration system and I want to provide a tooltip (ALWAYS VISIBLE) for each indicator as shown in my image bellow.

screenshot 1

HOWEVER:

  • I have noticed that when I create my tooltips using the <span> with Javascript as shown below, it will only work with hover event.

  • And when I create it with new bootstrap.Tooltip() it will work as intended as long as I call the .show() function as shown below in the code.

(FYI, the first tooltip shown in the image is actually the <span> and I'm hovering the mouse. The bootstrap.Tooltip() has style display: none only for blue indicator. So both <span> and bootstrap.Tooltip() overlap in case of display: block)

Something strange that I have also noticed is that when a tooltip is created via newbootstrap.Tooltip() a new <div> is created at the top of the page which will have the information of the <span> but will not take the id or className. It has it's own id which is random on every page reload (e.g. tooltip768493, tooltip714418, tooltip9188236)

What I'm trying to figure out is how to set a default className or id on each of the bootstrap.Tooltip() so that I can change their title dynamically as shown below:

  • Blue - You are here
  • Red - Missing or Invalid
  • Green - Valid
  • Grey - Optional

Here is how I created the tooltip targets:

   //in a for loop create 6 spans to hold tooltips:

   //Indicator Progress Span (above bullet with text) 
   span = document.createElement("span");
   span.className = "indicator-tooltip-target";
   span.style.zIndex = "3";
   span.setAttribute("data-toggle","tooltip");
   span.setAttribute("data-original-title", "test");
function show_tooltips(){
    let tooltips_target = document.getElementsByClassName("indicator-tooltip-target");
    for(var i=0; i<tooltips_target.length; i++){
        let tooltip = new bootstrap.Tooltip(tooltips_target[i]);
        tooltip.show();
    }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!