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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:43:48+00:00 2026-06-03T03:43:48+00:00

Im new to this.I have this jquery <script type=text/javascript> $(document).ready(function () { $(.squares div).click(function

  • 0

Im new to this.I have this jquery

<script type="text/javascript">
 $(document).ready(function () {
      $(".squares div").click(function () {
           var colorSource = $(this).css("background-color");
           $(".squares div").click(function () {
                $(this).css("background-color", colorSource);
                }
           });
      });
 });

basically when i click on square it save the color and than I click on another square and it copy the color. the problem is when I click on 3rd square it copy the color from the square I already change its color. what can I do?

  • 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-03T03:43:49+00:00Added an answer on June 3, 2026 at 3:43 am

    I think you want to copy the color of the last visited square, then try below,

      $(function () {
        var colorSource = '';
        $(".squares div").click(function () {
    
           if (colorSource== '') {
              colorSource= $(this).css("background-color");
           } else {
              $(this).css("background-color", colorSource);
              colorSource = ''; 
             //Originally ^-- colorSource= $(this).css("background-color");
           }
        });
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an inline script on my page as such: <script type=text/javascript> var rootPath
I'm really new to JavaScript and jQuery. My question is this. I have two
Im very new to all coding including jquery. I though this would have been
Am new to jquery. Have json response from php in this format. { div1:{data:minute=0,hour=27,day=649,month=19K,smallSize=0,
I'm new to jQuery so this may be a real simple answer. I have
hey people I'm new at jquery and i have been trying to figure this
I have this: var date = new DateTime(2009, 12, 5); ... ... and need
I am very new to javascript and ajax/jquery and have been working on trying
How I can load the Google maps like this: function loadScript() { var script
I'm learning javascript and jquery and have written a very basic script inside my

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.