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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:57:24+00:00 2026-05-17T22:57:24+00:00

I am following this thread to disable/ enable the click on a button, Best

  • 0

I am following this thread to disable/ enable the click on a button,
Best way to remove an event handler in jQuery?

its idea is that you can also use the live() method to enable/disable events. What will happen with this code is that when you click on an a tag-element, for instance, .load-item, it will add the class disabled to this element. This will make it so that the selector no longer matches the element and the event will not be fired until the ‘disabled’ class is removed making the .live() selector valid again.

Below is what I came out with and it does disable the click on the first button,

$('.load-item:not(.disabled)').live('click',function(){


/* add a .current class to the target item */
$(this).parentsUntil('.column-global').addClass('current');

/* add .disabled class to each a tag in the .current element-div */
$('.current a').each(function(index) {
    $(this).addClass('disabled');
});

....

});

and I have another function to remove the disabled-class when you click on another button,

$('.button-return').click(function(){

    ...

    /* remove all the .disabled class if any exists */
    $('.current a').each(function(index) {
        $(this).removeClass('disabled');
    });

    ...

    /* remove all the .current class if any exists */
    $('.item-global').removeClass('current');



    return false;

});

I have checked that it does remove the disabled-class, but the first button still is not back to the original clickable state.

have I missed out anything – or the live() actually only lives once only? any better solutions if live() is not the one I should work on??

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-17T22:57:24+00:00Added an answer on May 17, 2026 at 10:57 pm

    Your return button needs to be a live event as well

    $('.button-return:not(disabled)').live("click",function(){...});
    

    Also when using addClass() and removeClass() you do not need to use each on the selector. Just call it.

    $('.current a').each(function(index) {
        $(this).removeClass('disabled');
    });
    

    is the same as this

    $('.current a').removeClass('disabled');
    

    Edited

    Note when you add the live event to the return button you need to verify that it is not disabled.

    It works perfectly here is a simple demo. http://www.jsfiddle.net/Qax3n/

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

Sidebar

Related Questions

No related questions found

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.