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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:56:15+00:00 2026-05-21T10:56:15+00:00

I was reading a couple of tutorials. This is the link to one of

  • 0

I was reading a couple of tutorials. This is the link to one of them: http://blog.jeremymartin.name/2008/02/building-your-first-jquery-plugin-that.html

In it, the author says,

You’ll notice that whenever I needed to select an element within the plugin, I always used obj as my context (e.g., moreLink = $(‘.truncate_more_link’, obj)). This is necessary to constrain any selections to the current truncated element. Without setting the context like this, you will get unpredictable results.

I’ve read similar statements in other tutorials, but I still don’t grasp what they really mean. In my mind, I understand …

$('.truncate_more_link', obj)

… to mean, “Select elements with the .truncate_more_link class and also the element represented by the variable obj.”

But it sounds like the author of the tutorial is saying “Select the .truncate_more_link class elements that are also the actual element passed into the plugin function. Why not just do

$(obj)

instead of

$('.truncate_more_link', obj)  

It seems I’m missing some understanding of scope.

  • 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-21T10:56:16+00:00Added an answer on May 21, 2026 at 10:56 am

    When you pass two arguments to jQuery, the second argument is used as the "context" for the first. Short version: $('foo', bar) means exactly the same thing as $(bar).find('foo').

    Selector Context

    By default, selectors perform their searches within the DOM starting at the document root. However, an alternate context can be given for the search by using the optional second parameter to the $() function. For example, to do a search within an event handler, the search can be restricted like so:

    $('div.foo').click(function() {
      $('span', this).addClass('bar');
    });
    

    When the search for the span selector is restricted to the context of this, only spans within the clicked element will get the additional class.

    Internally, selector context is implemented with the .find() method, so $('span', this) is equivalent to $(this).find('span').

    http://api.jquery.com/jQuery/#jQuery1

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

Sidebar

Related Questions

After a couple of weeks reading on this forum I thought it was time
I vaguely remember reading about this a couple of years ago, but I can't
After reading a couple of tutorials on Steganography using Java/.NET I'm under the impression
I'v been reading through the Apple Docs, read through a couple tutorials online, and
I notice this has caused confusion for several people, but after reading a couple
The Java Tutorials listed a couple of books for further reading regarding threading /
I'm fairly new to DDD world and after reading couple of books about it
Hi clever programmers, I've been searching and reading a couple days, but I need
I searched for the past couple hours reading dozens of posts on the topic
I've been reading the facebook API for the past couple hours and unable to

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.