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

135
Visualizações
mouseenter and mouseover for over animation in jquery

I'm stuck on a jquery property. I want make an over effect with property mouse enter and mouse leave but i have several images and i would like to do it only on 1 when the mouse enters on this one.

I tried to put several class name but nothing does the hover effect this puts on all the images and not only on the active one.

<div id="villas">
                <div class="l_villa">
                    <a href="./img/villa1.png" alt="villa1">
                        <img id="lv1" src="./img/villa1.png" alt="villa1">
                    </a>
                    <div class="lvinfos1">
                        Lorem ipsum dolor sit amet.
                    </div>
                </div>

                <div class="l_villa">
                    <a href="./img/villa2.png" alt="villa2">
                        <img class="lv1" src="./img/villa2.png" alt="villa2">
                    </a>
                    <div class="lvinfos2">
                        Lorem ipsum dolor sit amet.
                    </div>
                </div>
$(document).ready(function(){
    $(".l_villa").mouseover(function(){
        $(".lvinfos1").slideUp("slow");

    });
    $(".l_villa").mouseleave(function(){
        $(".lvinfos1").slideDown('slow');

    });
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To do what you require change all the .lvinfosN elements to have the same class. I would suggest .lvinfos. Then in the event handler use the this keyword to refer to the element that raised the event, and use DOM traversal to target the related element to slide up or down. In this case find() will work.

Note that the code can be shortened by using the hover() method along with slideToggle(). In addition it's worth calling stop() as well to prevent multiple animations being queued when the user repeatedly mouses in/out of the element.

$(document).ready(function() {
  $('.l_villa').hover(function() {
    $(this).find('.lvinfos').stop(true).slideToggle("slow");
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div id="villas">
  <div class="l_villa">
    <a href="./img/villa1.png" alt="villa1">
      <img id="lv1" src="./img/villa1.png" alt="villa1">
    </a>
    <div class="lvinfos">
      Lorem ipsum dolor sit amet.
    </div>
  </div>

  <div class="l_villa">
    <a href="./img/villa2.png" alt="villa2">
      <img class="lv1" src="./img/villa2.png" alt="villa2">
    </a>
    <div class="lvinfos">
      Lorem ipsum dolor sit amet.
    </div>
  </div>
</div>

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