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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:26:06+00:00 2026-05-16T16:26:06+00:00

I am trying to change the background-image of a div by altering it’s CSS

  • 0

I am trying to change the background-image of a div by altering it’s CSS via Jquery and I got it to work in FireFox but for some reason its not doing anything in chrome, I tried clearing the cache but still no luck, there’s no errors in the console either, Here’s my code:

$(document).ready(function() {
    var bg = 1;
  $("#changePic").click(function () {
    if (bg == 1)
    {
        $("#outerWrapper").css("background-image","url(images/background-lodge1.jpg");
        bg=2;
    }
    else if (bg == 2)
    {
        $("#outerWrapper").css("background-image","url(images/background-lodge2.jpg");
        bg=3;
    }
    else
    {
        $("#outerWrapper").css("background-image","url(images/background-lodge.jpg");
        bg=1;
    }
  });
});

And then my link looks like this:

<a href="#" id="changePic"><span class="sidetab">Next Photo <img src="images/arrow.png" alt="" width="10" height="14" align="absmiddle" /></span></a>

Any ideas on why this would work in firefox but not chrome??

  • 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-16T16:26:07+00:00Added an answer on May 16, 2026 at 4:26 pm

    I can’t say for sure why it’s not working since #outerWrapper isn’t in your posted markup. Also where is this script? Is it possible it’s not being included correctly, possible a malformed <script> tag Chrome doesn’t like?

    What I can provide is a way to simplify it and still be cross-browser compatible, you can use .toggle() instead, like this:

    $(function() {
      $("#changePic").toggle(function () {
        $("#outerWrapper").css("background-image","url(images/background-lodge1.jpg");
      }, function() {
        $("#outerWrapper").css("background-image","url(images/background-lodge2.jpg");
      }, function() {
        $("#outerWrapper").css("background-image","url(images/background-lodge.jpg");
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've been trying to change the background image of the input button through css,
I'm trying to change the background image of a div when I click on
I am trying to change the background image of a div. I have stored
I'm trying to create a background position change with animation. but for some reason
I'm trying to dynamically change the background image of a div inside of a
I'm trying to change background-size using css: I want 100 heights and 100 widths,
I am trying to change the menuOption background-color on hover using JQuery. All my
Can't change the body background for some reason, here is how I am trying
I'm trying to change the background image set by xaml this way: <s:SurfaceWindow.Resources> <ImageBrush
Hey guys, I'm trying to change the background image of multiple divs with 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.