VOOZH about

URL: https://www.geeksforgeeks.org/jquery/what-is-the-difference-between-eq-and-get-methods-in-jquery/

⇱ What is the difference between eq() and get() methods in jQuery ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

What is the difference between eq() and get() methods in jQuery ?

Last Updated : 23 Jul, 2025

In this article, we will discuss all the differences between eq() and get() methods in jQuery. 

eq() Method: This method is used to locate the selected elements directly and returns an element with a specific index.

Syntax:

$(selector).eq(index)

Example: In this example, we will set the different text colors on the 0th and 2nd index paragraphs.

Output:

👁 Image

get() method: This method loads the data from the server by using the GET HTTP request. This method returns XMLHttpRequest object.

Syntax:

$.get( url, [data], [callback], [type] )

Example: In this example, we will get the data from the server and display it on the screen. This code will run on the server.

Filename: gfg.php

Filename: index.php

Output:

👁 Image

Difference between eq() and get() methods:

jQuery eq() Method

jQuery get() Method

This method return the element as a jQuery object.This method returns a DOM element.
This method retrieves the n-1th jQuery object.This method returns the n-1th DOM element.
This method creates a new object from one element within the set and returns it.This method retrieves the DOM element that matches the jQuery object.
Its return method in an element with index of selected elements.It helps in loading data from the server using a HTTP GET request

Its syntax is -:

$(selector).eq(index)

Its syntax is -:

$.get(URL,data,function(data,status,xhr),dataType)

It takes one parameter as a index.It takes one parameter as a URL.
Comment

Explore