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

102
Views
Having a problem with this method of creating a tooltip using Javascript

Our assignment is to watch the following video and using the author's method, create an HTML list, create a tooltip using Javascript for each list item and style the tooltip with CSS.

The video create tooltips for hyperlinks and I just needed to change it so the tooltip is for list items. Sounds simple but I'm having one problem; my CSS works for everything BUT the class tooltip.* The tooltip only shows up with default styling. Please help me figure out why.

Here's the video:

https://www.youtube.com/watch?v=ylWto93_rZM

and here's my code:

https://codepen.io/janicefore/pen/wvqmBOV


var Tooltip = {
opening: function() {
var theList = document.getElementsByTagName("li");
        
if ( theList ) {
for(var i = 0; i < theList.length; i++) {
if( theList[i].title.length) {
theList[i].addEventListener("mouseover", Tooltip.showTip);
theList[i].addEventListener("mouseover", Tooltip.hideTip);
}
                
}
}
},
        
showTip: function( event ) {
var spanElm = document.createElement( "span" );
spanElm.className = "tooltip";
spanElm.innerHTML = event.target.title;
        
event.target.title "";
event.target.appendChild( spanElm ); 
event.target._spanRef = spanElm;
},
        
hideTip: function ( event ) {
event.target.title = event.target._spanRef.innerHTML;
event.target.removeChild( event.target._spanRef );
};
        
window.addEventListener( "load", Tooltip.opening);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. javascript typo: mouseover -> mouseout
  2. javascript syntax error: event.target.title "";
  3. javascript syntax error: missing } for Tooltip = {
about 4 years ago · Juan Pablo Isaza Report
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!