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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:32:14+00:00 2026-05-13T20:32:14+00:00

The .first() method was added in jQuery 1.4. The :first selector has been around

  • 0

The .first() method was added in jQuery 1.4.

The :first selector has been around since 1.0.

From the docs:

:first

The :first pseudo-class is equivalent to :eq(0). It could also be written as :lt(1). While this matches only a single element, :first-child can match more than one: One for each parent.

.first()

Given a jQuery object that represents a set of DOM elements, the .first() method constructs a new jQuery object from the first matching element.


It seems that .first() is a filter that returns another jQuery object, while :first is just a selector.

But, they can both be used to accomplish the same thing.

So, when should one be used instead of the other? Performance? Please provide examples.

  • 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-13T20:32:15+00:00Added an answer on May 13, 2026 at 8:32 pm

    .first() can be used to select the first element in a jQuery collection.

    Basically, it avoids having to do a new query or break the chain in situations when you need to work on a collection and then exclusively on the first element.

    Actually, one of the most costly operations you can do in jQuery is a query. The less you do, the better it is…

    One example I can think of right now is an image gallery script where your first image is always the default active one, yet you need to attach an event handler on each image…

    $('#gallery img').click(myFunc).first().addClass('active');
    
    // Instead of
    $('#gallery img').click(myFunc);
    $('#gallery img:first').addClass('active');
    

    .first() is also syntactic sugar for something that exists since 1.1.2… .eq(0):

    $('#gallery img').click(myFunc).eq(0).addClass('active');
    

    in fact, that’s how it is implemented in jQuery itself:

    first: function() {
      return this.eq( 0 );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time attempting to call an ASP.NET page method from jQuery.
When programming by contract a function or method first checks whether its preconditions are
What is the meaning of the .NET 3.5 extension method Enumerable.First() when you call
The first thing I do in a public method is to validate every single
This is my first crack at a method that is run periodically during the
I know there is a method for a Python list to return the first
First off, according to http://msdn.microsoft.com/en-us/library/x0b5b5bc.aspx , the List.Find method is only listed as throwing
First, I know there are methods off of the generic List<> class already in
dict methods dict.keys() , dict.items() and dict.values() return views instead of lists. Source First
I'm hosting my first WCF service in IIS. I have two methods, 1 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.