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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:35:50+00:00 2026-05-25T12:35:50+00:00

I want to hide an element after it is first clicked (using jQuery), so

  • 0

I want to hide an element after it is first clicked (using jQuery), so that user can’t see and click the element after that.

How can I do that?

Thanks.

  • 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-25T12:35:50+00:00Added an answer on May 25, 2026 at 12:35 pm

    Very simply:

    $("selector").click(function() { $(this).hide(); });
    

    "selector" above would be any valid jQuery selector (e.g. ".click-to-hide" to make all elements with class click-to-hide have this behavior). Hiding the element is done using the jQuery hide method (there is also show if you want to make the elements visible again later).

    If you do not intend to do anything at all with the elements after they are hidden for the first time, you might also want to consider remove instead of hide.

    Update: To do something on the second click, you need to remember when a click has already been made on an element. If it’s not going to get more complicated than that, you could use a class for this purpose:

    $("selector").click(function() {
        var $this = $(this);
        if ($this.hasClass("clicked-once")) {
            // already been clicked once, hide it
            $this.hide();
        }
        else {
            // first time this is clicked, mark it
            $this.addClass("clicked-once");
        }
    });
    

    If you want to count the clicks, you can use the data function to store the amount of clicks the element has received:

    $("selector").click(function() {
        var $this = $(this);
    
        // Current click count is previous click count +1
        var clickCount = ($this.data("click-count") || 0) + 1;
    
        // Save current click count
        $this.data("click-count", clickCount);
    
        if (clickCount == 1) {
            $this.hide();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the live method to hide an element if the user
Given an IBOutlet pointer in Objective-C/iPad, how do you hide that element? Want to
I've got a simple dropdown menu that I want to hide whenever you click
Is there a way in jQuery where I can hide an element, but not
Trying to show/hide severals divs using jquery after each news on my page. <div
I want to hide a DIV element after the previous effects/movements have completed. If
I want to hide the Next button on my ASP.NET Wizard control using JavaScript.
I want to hide the cursor when showing a webpage that is meant to
I want to hide all mysql error messages without using mysql_error() . Are there
I have a flex app that I want to hide in a div until

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.