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

134
Views
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 answers
Answer question

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 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!