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

The Archive Base Latest Questions

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

I have a newbie question about jQuery. Why is it that I can trigger

  • 0

I have a newbie question about jQuery. Why is it that I can trigger the click event below even though the element has changed class? Even though I change the class from “edit” to “tide”, $(“.edit”).click() is working on that element.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript" src="jquery-1.4.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $(".edit").click(function(){
                console.log(this);
                $(this).removeClass("edit").addClass("tide");
            });
        });
    </script>
</head>

<body>
    <div class="edit">Hi there</div>
</body>
</html>

Thank you!

  • 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:52:39+00:00Added an answer on May 17, 2026 at 10:52 pm

    If you want that behavior, use .live(), like this:

    $(document).ready(function(){
        $(".edit").live('click', function(){
            console.log(this);
            $(this).removeClass("edit").addClass("tide");
        });
    });
    

    You can test it out here. As it is now, $(".edit") finds elements that match the .edit selector at that time and binds to them, those click event handlers are in no way dependent upon the class name after that. With .live() the selector is evaluated at the time of the event, so it does matter.

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

Sidebar

Related Questions

Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
I have a newbie question about Git: I need to move back and forth
I have a newbie question about the following: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
i'm a pl/sql newbie. now i have a question about oracle type . i
Another newbie question. The goal: each ingredient can have zero or more unit conversions
MVC newbie question re binders. Supposing I have two strongly typed partial actions that
I am a newbie to WPF and have a couple of questions about WPF
This is sort of SQL newbie question, I think, but here goes. I have
Pardon the dumb newbie question here; web programming isn't my forte... (blush) I have
As being quite a newbie in linux, I have the follwing question. I have

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.