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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:39:34+00:00 2026-06-18T01:39:34+00:00

I felt very confused about this keyword in jquery 1.7.3 source.some snippets showing below:

  • 0

I felt very confused about “this” keyword in jquery 1.7.3 source.some snippets showing below:

jQuery.fn = jQuery.prototype = {
constructor: jQuery,
init: function( selector, context, rootjQuery ) {
    var match, elem, ret, doc;

    // Handle $(""), $(null), or $(undefined)
    if ( !selector ) {
        return this;   
    }

    // Handle $(DOMElement)
    if ( selector.nodeType ) {
        this.context = this[0] = selector;
        this.length = 1;
        return this;
    }

if ( !selector ) {

  return this;   //why not only one "return" here?
                 //And does "this" refer to jQuery object?
                 //OTOH, this question is about why it returns "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-06-18T01:39:35+00:00Added an answer on June 18, 2026 at 1:39 am

    return this allow for chainable plugin call,

    $(whatever).plugin1().plugin2() etc
    

    if you don’t return this in a plugin you won’t be able to chain it
    & chaining is fast, & chaining is cool
    you want to chain as much as possible in your jquery code

    to answer your comment : no you do (inside plugin definition):

    if ($("#div1").get(0)) {
       //do whatever to $("#div1")
       }
    return this;
    

    return this comes at the end of plugin definition no need to return it upon any condition whatsoever

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

Sidebar

Related Questions

I've a question about weka as this person: Hi all: I felt really strange
After reading this post I kinda felt in the same position as the guy
This is probably a very strange request. I need to programmaticaly (via code) change
I'm doing some due diligence into a project whereby a user can very heavily
When I went through different demos of WebGL online, I really felt it's very
I felt like I'm having the same issues as addressed here . But everything
I've always felt like SecureString was a little odd, but assumed most of my
how could i implement autosave in C#? i felt that saving to the currently
I am python/django developer. As a part of improving my knowledge and felt like
Back in my C/C++ days, coding an infinite loop as while (true) felt more

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.