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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:05:00+00:00 2026-05-27T08:05:00+00:00

Ok not sure whats going on the code does toggle class, but when you

  • 0

Ok not sure whats going on the code does toggle class, but when you click it again it is well seen that the class is removed however the text remains the same “Locked…” and is not changed back to the original.

Here is the jQuery code

$("#sprv").click(function() {
                 $(this).toggleClass('btn_active');

                 $(".prv").text("Make private?");

                 }, function(){

                 $(this).toggleClass('btn_active');

                 $(".prv").text("Locked...");
});

<span class="prv">Make private?</span>

Can some one tell me what I am doing wrong and how to fix this. Thanks in advance

  • 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-27T08:05:01+00:00Added an answer on May 27, 2026 at 8:05 am

    You are passing two functions into the click handler. You can’t do that (it is interpreting the first function as the eventdata, and the second function as the handler — see http://api.jquery.com/click/). You need to pass just one event handler. It can deal with both cases though, like this:

    $('#sprv').click(function() {
        $(this).toggleClass('btn_active');
        $('.prv').text($(this).hasClass('btn_active') ? 'Locked...' : 'Make private?');
    });
    

    First it toggles the class, then it uses jQuery.hasClass() to determine if it has the btn_active class. It always updates the text, but it uses a value according to the state (determined from the just-toggled class).

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

Sidebar

Related Questions

I'm not sure of what's going on here, but I have some python code:
Not sure what's going on here, but my iPhone apps nav bar shows back
I'm not sure what's going on, but on my own laptop, everything works okay.
Not sure what exactly is going on here, but seems like in .NET 1.1
I'm not too sure what is going on here, but sometimes a particular file
Now I'm not really sure what the problem here is but it seems that
I am not sure what is going on, but i get this weird issue
Can you explain what's going on with my code here? I'm not sure if
Not sure what is going on. When I perform the following code... it runs
Not sure what's going on here. I have a DateTime object, and when I

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.