Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

104
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda