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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:12:47+00:00 2026-05-27T19:12:47+00:00

I think that I am misunderstanding something about how jquery $(this) works. In my

  • 0

I think that I am misunderstanding something about how jquery $(this) works. In my code below:

$(document).delegate(".ISBN_number", "change", 
        function()
        {
            var isbnNum = $(this).val();
            console.log("isbnNum = " + isbnNum);
            $.get("validate_isbn.php", {isbn: isbnNum},
                function(answer) 
                {                   
                    console.log("answer = " + answer);    //this does display the correct content
                    if (answer == true)
                    {   console.log("entered answer");
                        $(this).after("<img src='pics/green_checkmark.png' class='checkmark'>");
                    }
                    else 
                    {
                        $(this).after("nope");
                    }
            });             
    });

I am trying to select any input tag when its contents are changed. When I call $(this) in the code, I assumed that it would refer back to this input tag but it doesn’t. What is my issue? Is it because I used .delegate? (I needed to use this because the input tags are generated dynamically later on, they don’t exist in the original code.) How can I fix this?

  • 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-27T19:12:47+00:00Added an answer on May 27, 2026 at 7:12 pm

    If you want to access this from the .delegate() call, then you have to save it into a local variable because this is set to something different in the completion function for the ajax call. You can do that like this:

    $(document).delegate(".ISBN_number", "change", 
            function()
            {
                var self = this;
                var isbnNum = $(this).val();
                console.log("isbnNum = " + isbnNum);
                $.get("validate_isbn.php", {isbn: isbnNum},
                    function(answer) 
                    {                   
                        console.log("answer = " + answer);    //this does display the correct content
                        if (answer == true)
                        {   console.log("entered answer");
                            $(self).after("<img src='pics/green_checkmark.png' class='checkmark'>");
                        }
                        else 
                        {
                            $(self).after("nope");
                        }
                });             
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I'm misunderstanding something about how this works. This is my fluent mapping:
Ok so I think I must be misunderstanding something about SQL queries. This is
I think that this problem can be sorted using reflection (a technology which I'm
I think that some newer languages like JS can do this natively, but I
I think that looking at others' code is a good way to learn. I'm
I think I have some fundamental misunderstanding of how the Qt signal/slot mechanism works.
Am I misunderstanding something about bindings? I bind (an NSArrayController's content) to an NSDictionary's
I think that handlers in android are tools to get different objects that are
I think that I'm probably not writing lazily instantiated methods/attributes in the most ruby
just think that when I opened my file then when I want to write

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.