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 9178167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:29:20+00:00 2026-06-17T17:29:20+00:00

i am wanting to implement a solution where: whilst contents in div #content are

  • 0

i am wanting to implement a solution where:

  1. whilst contents in div #content are loading,
  2. hide div #content,
  3. show div #loading,
  4. then when div #content has loaded,
  5. hide div #loading,
  6. fade in div #content

i have tried:

html:

<div id="content">
<!--this stuff takes a long time to load-->
<img src="http://lorempixel.com/1920/1920/">
</div>
<div id="loading">
<!-- this is the loading gif -->
<img src="http://lorempixel.com/400/200/">
</div>

js:

// when user browses to page
$('#content').hide();
$('#loading').show();

// then when div #content has loaded, hide div #loading and fade in div #content
$('#content').bind('load', function() {
$('#loading').hide();
$('#content').fadeIn('slow');
});

here is the jsfiddle i am working on:

http://jsfiddle.net/rwone/Y9CQ4/

thank you.

  • 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-17T17:29:21+00:00Added an answer on June 17, 2026 at 5:29 pm

    According to .load(), the event should fire, when

    The load event is sent to an element when it and all sub-elements have been completely loaded. This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.

    So, you cannot bind the load event handler to a div tag. When you want the event handler to fire after the image has loaded, you must bind it to the image

    HTML:

    <div id="content">
    <!--this stuff takes a long time to load-->
    <img id="large" src="http://lorempixel.com/1920/1920/">
    </div>
    <div id="loading">
    <!-- this is the loading gif -->
    <img src="http://lorempixel.com/400/200/">
    </div>
    

    JS:

    // when user browses to page
    $('#content').hide();
    $('#loading').show();
    
    // then when the #content div has loaded
    $('#large').bind('load', function() {
    $('#loading').hide();
    $('#content').fadeIn('slow');
    });
    

    JSFiddle

    Or you can bind the event to the window object, which fires when

    the page is fully loaded including graphics.

    JS:

    $(window).bind('load', function() {
    $('#loading').hide();
    $('#content').fadeIn('slow');
    });
    

    JSFiddle

    Yet a third approach, would be to test if all images are loaded, when the load event fires

    function allImagesLoaded() {
        var imgs = $(this).closest('div').find('img');
        var loaded = 0;
        imgs.each(function() { if ($(this.complete)) ++loaded; });
        if (imgs.length == loaded) {
            $('#loading').hide();
            $('#content').fadeIn('slow');
        }
    }
    
    // when user browses to page
    $('#content').hide();
    $('#loading').show();
    
    // then when the #content div has loaded
    $('#content img').bind('load', allImagesLoaded);
    

    JSFiddle

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

Sidebar

Related Questions

i own a translation service and now im wanting to implement a TTS solution.
I'm wanting to extract a zip file loaded with images into memory in some
I found myself wanting to implement an IAwaitable class (something that implements asynchronous calls
I have a console application that prints on standard output. I want to implement
I'm wanting to implement a particular functionality in a MySQLi extension that I'm creating,
I downloaded the latest jQuery UI from their Themeroller site wanting to implement ui-checkboxes
Wanting to implement authentication by client certificates I am experiencing some issues. First some
I am wanting to implement automated testing, using the Microsoft testing framework in Visual
I am trying to implement an operation queue and I have the following scenario:
Wanting to give byobu a looksee as a screen 'update' of sorts. I start

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.