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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:18:19+00:00 2026-05-11T11:18:19+00:00

As a jQuery neophyte I am somewhat confused by the different contexts in which

  • 0

As a jQuery neophyte I am somewhat confused by the different contexts in which the this keyword is used. Sometimes it refers to a DOM element e.g. this.id and sometimes it refers to a jQuery object e.g. $(this).val().

Remy Sharp’s blog post is helpful but I would like to know how you would explain the difference to a novice. Is the difference strictly a jQuery issue or common to all Javascript?

Thanks for all the responses so far – great stuff, I will pick an answer tomorrow. Here is another blog post I subsequently came across that was also helpful: What is this? by Mike Alsup.

  • 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. 2026-05-11T11:18:20+00:00Added an answer on May 11, 2026 at 11:18 am

    Remy Sharp’s post is confusing if you don’t read it carefully, in my opinion. The meaning of this never changes. In the example you gave, there were 2 uses of this. As a DOM element in an event:

    $('a').click(function() {     alert(this.tagName); }); 

    and wrapped as a jQuery object in an event:

    $('a').click(function() {     alert($(this).val()); }); 

    If you read the 2 snippets above very carefully you’ll notice that this never changes meaning. It always refers to the DOM element. The difference comes in how it is used.

    In jQuery, by default, this refers to the DOM element (not a jQuery object) which triggered an event. In the second code snippet above, it is still the same DOM element, only it is wrapped in a jQuery element by wrapping $() around it. As with any argument to the jQuery constructor, passing this into the constructor transforms it into a jQuery object.

    I think the confusion comes in when Remy starts talking about jQuery plugins in the same article as jQuery events. jQuery plugins are something that people rarely write and frequently use. When writing a jQuery plugin, you’re working within the context of the jQuery object prototype. In this case, you’re using the word this to refer to the plugin you’re writing. In normal use-cases, you won’t be writing plugins often so this is a much less common scenario. When not in the scope of the plugin, you can’t use this to refer to the jQuery object.


    In the JavaScript language, the keyword this refers to the current instance of an object in JavaScript. When being used in a JavaScript prototype, it refers to the instance of the prototype. Depending on the browser, when using the non-jquery event model, this also refers to the DOM element. Because some browsers (Internet Explorer) don’t refer to this as the DOM element in an event, it makes working with events difficult. To get around this, jQuery performs some JavaScript magic that always makes this refer to the DOM element which triggered the event. That is (one of the many) reasons to use a JavaScript framework instead of rolling your own.

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

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer At step 1 you can call GetModuleFileName and pass in… May 11, 2026 at 12:32 pm
  • added an answer Ok I wish i could delete this question. I was… May 11, 2026 at 12:32 pm
  • added an answer There are two separate issues - one, you probably want… May 11, 2026 at 12:32 pm

Related Questions

I'm looking for a plugin for jQuery that can validate as a key is
I have to preface this with the fact that I love jQuery as a
In jQuery you can get the top position relative to the parent as a
I want to submit a with using jquery as below; $(#formid).submit(); Its working perfect
I'm using jQuery to add an additional row to a table as the last
I am trying to put some jquery UI code into an existing asp.net app,
I am starting to redesign and develop a site that contains a lot of
I am concerned with using CSS classes that are defined in style sheets with
I have an array I've created in JavaScript. The end result comes out to
I'm trying to make a quick jquery plugin (as a learning exercise) for making

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.