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

  • SEARCH
  • Home
  • 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 3951714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:45:49+00:00 2026-05-20T01:45:49+00:00

Here’s some sample code that I want to control using jQuery (white button bg

  • 0

Here’s some sample code that I want to control using jQuery (white button bg on black page bg):

    <ul class="buttons">
        <li class="button-displays"><a href="/products/">Products and Services for the company</a></li>
        <li class="button-packaging"><a href="/packaging/">Successful packaging services for the company</a></li>
        <li class="button-tools"><a href="/tools/">Data, mail and print tools for your company</li>
    </ul>

In the CSS file, I have the following:

    .buttons li { background-image: url(images/sprite.png); height:126px; width:293px; float:left; margin:0 0 0 9px; }
    .button-displays { background-position: 0 125px; }
    .button-packaging { background-position: 0 250px; }
    .button-tools { background-position: 0 375px; }

I have styled these list items to look like clickable buttons with the background sprite helping to fill out the background of the buttons.

My client doesn’t like that in Firefox and Safari, when the page loads for the first time, the text inside the anchor loads first then the background sprite of the li (which is around 150kb b/c I have a total of 6 buttons) loads only when the sprite is fully downloaded. The background suddenly appears after a couple of seconds of downloading leaving the text in the anchor by itself until the background pops in.

I have tried playing with the following code in hopes that it would delay the loading of this markup and CSS:

    $('.buttons li a').load(function() {
    });

and

    $(window).load(function() {
        $(.buttons);
    });

I do not understand jQuery enough to know if this forces the code to wait until all elements load before appearing. I’d rather force the list item elements in the buttons code to delay appearing on the page until the bg img sprite is completely loaded.

Thanks for your help and suggestions!

  • 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-05-20T01:45:49+00:00Added an answer on May 20, 2026 at 1:45 am

    I don’t think you can attach a load event specifically for background images.

    Try this instead:

    Make the .button li elements display:none:

    .buttons li { display:none; background-image: url(images/sprite.png); height:126px; width:293px; float:left; margin:0 0 0 9px; }
    

    Then in your jQuery, create an image with the URL of your sprite, and attach a load handler to it that will show the buttons.

    $(function() {
          // create a dummy image
        var img = new Image();
    
          // give it a single load handler
        $(img).one('load',function() {
            $('.buttons li').fadeIn(); // fade in the elements when the image loads
        });
    
          // give it the src of your background image
        img.src = "images/sprite.png";
    
          // make sure if fires in case it was cached
        if( img.complete )
            $(img).load();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
This is beyond both making sense and my control. That being said here is
here a a piece of code that is supposed to loop over and over
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
Here, i have coded to get data from DB. I want to store the

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.