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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:00:47+00:00 2026-06-01T16:00:47+00:00

Not a full-time jQuery nor Javascript dev so sorry if dumb question. I think

  • 0

Not a full-time jQuery nor Javascript dev so sorry if dumb question. I think I need something like the live function for a swapping of class’s I do to handle which value is tied to a selector.

I basically have markup that looks like this:

for unenabling:

<span id="enable-1695" data-id="1695" class="unenable-item">unenable</span>

for enabling:

<span id="enable-1695" data-id="1695" class="enable-item">enable</span>

I’d like to use toggleClass to update to enable-item after unenable is clicked. Also, I need the selector to update the runtime to these new values. I think this used to happen via the live method. How would I achieve this. I am currently doing it manually but the Javascript runtime doesn’t update the event handling correctly.

What javascript would I use to ensure that this worked correctly?

Any help is apprecciated.

thx

  • 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-01T16:00:49+00:00Added an answer on June 1, 2026 at 4:00 pm

    Firstly, perhaps “disable” might be a better word-choice here, but we’re not here to nitpick grammar…

    I’ll assume that when you click the ‘unenable’ link, it should change to be an ‘enable’ link:

    $('.unenable-item').live('click', function () {
        $(this)
            .removeClass('unenable-item')
            .addClass('enable-item')
            .text('enable');
        doSomethingWith($(this).data('id'));
    });
    $('.enable-item').live('click', function () {
        // the inverse of the above
    });
    

    Here, I used the live function which kinda-sorta is like .on or its deprecated alias .bind, except that it doesn’t actually attach the event handler to the objects selected by the selector. Instead it attaches a handler to the document and whenever there is a click on anything, it checks the selector then to see if it matches. You could also use .delegate for more-targetted matching. Better explanation of these things exist in the documentation (linked).

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

Sidebar

Related Questions

I am trying to do this, I'm a full time front-end dev and am
How is your javaScript code organized? Does it follow patterns like MVC, or something
i'm not a full RoR developer (php developer mostly), i've only don't small projects/tutorials,
I recently upgraded to SQL Management Studio 2008 (full not express, if it matters).
When I click with a full finger (not just a gentle touch) on or
In Visual Studio 2008, in the Find Results window, how do I not show the full
When I say full I mean a language that's not an extension to some
It seems that my Sql Server Full text catalog is not always up to
GLSL has a full C-style preprocessor. The only thing that does not work is
i've playing around with mysql's full text search and I'm not sure if it

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.