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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:48:04+00:00 2026-06-10T15:48:04+00:00

I have a simple HTML : <div id=wrapper></div> and this style sheet: #wrapper{ position:

  • 0

I have a simple HTML : <div id="wrapper"></div> and this style sheet:

#wrapper{

        position: absolute;

        width: 400px;
        height: 400px;     

        background-image: url(img1.png), url(img2.png);

        background-repeat: no-repeat, no-repeat;

        background-position: top center, center center;

        background-color: green;
        border: 1px solid black;

}  

as above style sheet shows #wrapper has two background images in different positions.
I want to change second image position on mouse click with applying no change on the first image position. what syntax do i have to use?

my jquery code :

$("#wrapper").click(function(){
    this.css("background-position": " ? , bottom right " );
});

i think ? should be replaced with something like !important but !important does not works for applying no change on first image.

position of both background images will change in different places, and i dont know what is the first image position now, i can save its position in a variable, but i rather to use native solution, if exists
any suggestion?

  • 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-10T15:48:05+00:00Added an answer on June 10, 2026 at 3:48 pm

    change background position 2

    This will replace the second background position (after comma) with bottom right:

    $('#wrapper').click(function() {
        $(this).css('background-position', function() {
            return this.style.backgroundPosition.replace(/,(.*)$/, ', bottom right');
        });
    });
    

    change background position 1

    And this will replace the first background position (before comma) with bottom right:

    $('#wrapper').click(function() {
        $(this).css('background-position', function() {
            return this.style.backgroundPosition.replace(/(.*),/, 'bottom right, ');
        });
    });
    

    this solution is a good choice if element has only two backgrounds and we want to change position or any other property of each background images

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

Sidebar

Related Questions

I have a seemingly simple html construct: <div class=featured-image img-wrapper full-width> <a href=http://localhost/wordpress/?p=26> <img
I have this simple html: <div class=wrapper> <span class=higher> [higher] <span class=lower> hello </span>
I have simple HTML page with svg like this: <div id=plan> <svg xmlns=http://www.w3.org/2000/svg version=1.1>
I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>
I have this simple js tabs. Here is the html : <div class=product-collateral> <div
I have a simple html form. This form has a specific width and margin
I am sure this is simple but... I have the following: http://jsfiddle.net/SUBH3/1/ HTML: <div
i have simple html that looks like this : <div class=img> <a target=_blank href=kl_big.htm
I have created a simple layout using the HTML div tag. I would like
I have a very simple HTML/JS code, which expands the size of a div

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.