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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:32:41+00:00 2026-05-27T22:32:41+00:00

Here is my code: http://jsfiddle.net/XYbmE/75/ I want the div#first to stay blue if the

  • 0

Here is my code: http://jsfiddle.net/XYbmE/75/

I want the div#first to stay blue if the black box is there. The black box only appear if i click on the div#first. If i click anywhere else the blackbox should be hidden and the div#first should be back red.

What should 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-05-27T22:32:42+00:00Added an answer on May 27, 2026 at 10:32 pm

    This looks like a job for classes!

    When the click event is triggered, add a class to #first that has the same CSS as :hover.

    div#first:hover,div#first.hover{
     width:200px;
     height:200px;
     background-color:blue;
    }
    

    And then, add the class on click:

    $('#first').click(function() {
      $(this).addClass('hover');
      $('#second').show();
    });
    

    Remove the class and black box, when you click elsewhere:

    $('body').click(function(e) {
        if(!$(e.target).is('#first')){
            $('#first').removeClass('hover');
            $('#second').hide();
        }
    });
    

    DEMO: http://jsfiddle.net/EjKKP/

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

Sidebar

Related Questions

I put my example code here http://jsfiddle.net/8epWm/2/ I want to enable zClip on an
I want to get the content of multiple Spans. Here is my code: http://jsfiddle.net/4XumV/
You can play with my code here: http://jsfiddle.net/gqQnd/ Basically I want to have a
jquery how to addClass to all the ul.menu li:first.selection ? demo code here: http://jsfiddle.net/NkbDY/
Here's my code: http://jsfiddle.net/ZspZT/ As you can see from the example, the fourth div
JSfiddle (showing the non-working code) here: http://jsfiddle.net/ts2Rr/ I have three boxes that a user
Here's the code http://jsfiddle.net/DTYEB/ after dropping the element into the dropbox if I put
Here is the code: http://jsfiddle.net/ym2GQ/ p { background: lightblue; } .end { background: orange;
Here is the code: http://jsfiddle.net/Gr3fT/1/ How to filter personRoles by role property? Each list
I have this code here http://jsfiddle.net/RzBeM/65/ you will see two input fields called quantity.

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.