Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:28:09+00:00 2026-06-15T23:28:09+00:00

Hi i have this javascript function which fades in a div if a user

  • 0

Hi i have this javascript function which fades in a div if a user hovers over another div. And when they hover off or more the mouse away the div fades back out.

Does anyone know how i can loop this to run an infinite number of times because at the moment it only does it the once.

<script>
$(".change-profile-pic").hide();
$('.img-with-border').hover(function () {
    if ($('.change-profile-pic').is(":hidden")) {
         $('.change-profile-pic').fadeTo(0, 500);
    } else {    
        $('.change-profile-pic').fadeTo(500, 0);              
    }
});
</script>     
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:28:10+00:00Added an answer on June 15, 2026 at 11:28 pm

    If you really want to use jQuery (not CSS transitions) then with .hover, .fadeIn and .fadeOut and my understanding of

    i want it to run again and again each time a user moves their mouse over it and away from it

    $(".change-profile-pic").hide();
    $('.img-with-border').hover(
        function over() { // fade in on mouseover
            $('.change-profile-pic').fadeIn(500);
        },
        function out() { // fade out on mouseout
            $('.change-profile-pic').fadeOut(500);
        }
    );
    

    Edit for no fade out when hovering over .change-profile-pic

    (function setUpHover() {
        $(".change-profile-pic").hide();
        var timeout = null,
            over = function over() {
                window.clearTimeout(timeout);
                $('.change-profile-pic').fadeIn(500);
            },
            outAfterDelay = function outAfterDelay() {
                $('.change-profile-pic').fadeOut(500);
            },
            out = function out() {
                timeout = window.setTimeout(outAfterDelay, 1000); // give enough time to move to elm here
            };
            
        $('.img-with-border').hover(over, out);
        $('.change-profile-pic').hover(over, out);
    }());
    

    Example fiddle (based on jfriend00‘s demo with JavaScript from this answer instead)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an onclick function which performs several tasks. In another JavaScript function I
In my page I have severals divs. When the user hovers over 1 div
I have this JavaScript function which is working in all the machines I tried
I have this JavaScript function which counts down until you can click the download
I have this Javascript function that sends username and password to php file through
So I have this javascript function, it sends an ajax requests to fetch a
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
As you may know, when we have this code in Javascript : function getName()
I have this JavaScript: var Type = function(name) { this.name = name; }; var
I have this javascript code <Script> function getGroupId(){ var group=document.getElementById(selectedOptions).value; var groupFirstLetter=group.substring(2); } </Script>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.