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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:15:28+00:00 2026-06-12T06:15:28+00:00

Based on a question answered earlier on SO, I’ve make this script which adds

  • 0

Based on a question answered earlier on SO, I’ve make this script which adds a CSS class to an element onClick. The problem is that it only works one time. How do I reset the function?

This is the jQuery code:

jQuery(function() {
jQuery('.close-button').click(function(){
    jQuery(".content-display").addClass("cover");
    jQuery(".close-button").addClass("cover");
});

jQuery('.project').click(function(){
    jQuery('.content-display').addClass("uncover");
    jQuery('.close-button').addClass("uncover");
    }); 
});

And a fiddle with everything.

  • 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-12T06:15:30+00:00Added an answer on June 12, 2026 at 6:15 am

    You need to remove alternative class on action. After you press both close and project in your current code, you have both cover and uncover classes

    jQuery(function() {
       jQuery('.close-button').click(function(){
           jQuery(".content-display").addClass("cover").removeClass("uncover");
           jQuery(".close-button").addClass("cover").removeClass("uncover");
       });
    
       jQuery('.project').click(function(){
           jQuery('.content-display').addClass("uncover").removeClass("cover");
           jQuery('.close-button').addClass("uncover").removeClass("cover");
       }); 
     });
    

    For this particular case usage of uncover class seems to be unnecessary, I vote for simple removeClass solution (@Stuart Feldt)

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

Sidebar

Related Questions

Earlier, I answered this question , which was basically about removing a table row.
Based on this question I've created a small application which is catching all debug
This question is based on my previous question which I got a working answer
Based off of a previous question I asked, which @Andrie answered, I have a
This question is based on another question of mine (thankfully answered). So if in
I recently answered this question based on my experience: Counting rows before proceeding to
This pertains to my question yesterday, which was answered perfectly here by @iambriansreed. In
Sorry for this based question. I am fresh to jqplot and would like to
I am working on a project which is basically a knowledge based question answering
This is a question based on: Trying to get tag-it to work with an

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.