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

The Archive Base Latest Questions

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

I have a div, with a specific style(let’s say a certain background). What I

  • 0

I have a div, with a specific style(let’s say a certain background).

What I want is, when one clicks on a list element having that div applied another specific style (another background type) to be applied to that div,

If another area in a different element belonging to that div is clicked, the style should not change.

Is it possible using jquery? thank you!

Edit: (my function does some other things also. but the changing color doesn;t work as i want. it changes the background of all items i click, not only the last clicked.)

$(document).ready(function() {
    $('.product_types > li').click(function() {
        $(this)
        .css('backgroundColor','#EE178C')
        .siblings()
        .css('backgroundColor','#ffffff');

        $('#submit_button').removeAttr('disabled');
        $('#number').removeAttr('disabled');
    });
});
  • 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-22T17:06:27+00:00Added an answer on May 22, 2026 at 5:06 pm

    As what I have understand on your question, this is what you want.

    Here is a jsFiddle of the below:

    $('.childDiv').click(function() {
      $(this).parent().find('.childDiv').css('background-color', '#ffffff');
      $(this).css('background-color', '#ff0000');
    });
    .parentDiv {
      border: 1px solid black;
      padding: 10px;
      width: 80px;
      margin: 5px;
      display: relative;
    }
    .childDiv {
      border: 1px solid blue;
      height: 50px;
      margin: 10px;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    <div id="divParent1" class="parentDiv">
      Group 1
      <div id="child1" class="childDiv">
        Child 1
      </div>
      <div id="child2" class="childDiv">
        Child 2
      </div>
    </div>
    <div id="divParent2" class="parentDiv">
      Group 2
      <div id="child1" class="childDiv">
        Child 1
      </div>
      <div id="child2" class="childDiv">
        Child 2
      </div>
    </div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have this markup: <div class=foobar> <div style=height:expression(this.parent.style.height + 'px')></div> </div> My
I have div containing a list of flash objects. The list is long so
I have a div container and have defined its style as follows: div#tbl-container {
I have a div with two nested divs inside, the (float:left) one is the
I have a div element that has an id and this div contains a
I have a container div element that has overflow:hidden on it. Unfortunately this property
i have this code <div id=aggregate style=display:inline> <%=Html.RadioButton(a, 1, true, new {id = meRadio})%><label>Me</label>
I have several vertically stacks divs and I want to have a div appear
I have a div and an iframe on the page the div has z-index:
I have a div in which a page is loaded with the DojoX Layout

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.