Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
How to target an id inside of a div class when I hover a different parent div class with jquery?

So as the question says, I am trying to hover the class button1 and get the id of 'css'. With my current code, all I get is the id html. I need to get a unique id that's pertinent to which button I hover. I'm still newer to jquery and javascript in general but I can't seem to find any information on this topic so any reference source would be great too if possible.

Here's my code:

HTML

<div class="button1">       
     <div class="text">
          <p>Skill<br /> <span class="Score" id = "html">10/10 </span> </p>
     </div>

     <div class="button1 Overlay">
     </div>
<div class="button1">       
     <div class="text">
          <p>Skill<br /> <span class="Score" id = "css">9/10 </span> </p>
     </div>

     <div class="button1 Overlay">
     </div>
</div> 

Jquery

('.button1').mouseover(function(event) {
    $(".text").attr('id');
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

With your current code you get nothing, since .text does not have ID and result is never used. Use $(this).find('.Score').attr('id')[1].

Note few bug fixes:

  1. ('.button1').mouseover is missing $
  2. You have nested .button1 (first one is not properly closed, use proper indentation for easier debugging), so it's impossible to find singe element, because you hover on top most element

$('.button1').mouseover(function(event) {
  console.log($(this).find('.Score').attr('id'))
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="button1">
  <div class="text">
    <p>Skill<br /> <span class="Score" id="html">10/10 </span> </p>
  </div>

  <div class="button1 Overlay">
  </div>
</div>
<div class="button1">
  <div class="text">
    <p>Skill<br /> <span class="Score" id="css">9/10 </span> </p>
  </div>

  <div class="button1 Overlay">
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda