What is the difference between eq() and get() methods in jQuery ? Last Updated : 10 Aug, 2022 Comments Improve Suggest changes Like Article Like Report 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. HTML <!DOCTYPE html> <html> <head> <title>jQuery eq() Method</title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> </head> <body style="text-align: center;"> <h1 style="color: green;"> GeeksforGeeks </h1> <h3>jQuery eq() Method</h3> <p class="text">HTML</p> <p class="text">CSS</p> <p class="text">JavaScript</p> <script> $(document).ready(function () { $(".text").eq(0).css("color", "red"); $(".text").eq(2).css("color", "blue"); }); </script> </body> </html> Output: 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 PHP <?php if( $_REQUEST["name"] ) { $name = $_REQUEST['name']; echo "A ". $name . " portal for geeks"; } ?> Filename: index.php HTML <!DOCTYPE html> <html> <head> <title> CSS get() Method </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> </head> <body style="text-align: center;"> <h1 style="color: green;"> GeeksforGeeks </h1> <h3>CSS get() Method</h3> <div id="GFG"> Welcome to GeeksforGeeks </div> <br> <input type="button" id="Geeks" value="Load Data" /> <script> $(document).ready(function () { $("#Geeks").click(function (event) { $.get( "gfg.php", { name: "Computer Science" }, function (data) { $('#GFG').html(data); }); }); }); </script> </body> </html> Output: 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 More infoAdvertise with us Next Article What is the difference between eq() and get() methods in jQuery ? V vkash8574 Follow Improve Article Tags : Difference Between Web Technologies JQuery Geeks Premier League Geeks-Premier-League-2022 jQuery-Methods jQuery-Questions Web Technologies - Difference Between +3 More Similar Reads Difference between text() and html() method in jQuery Text() Method: This method returns the text content of the selected elements. It overwrites the content of all the matches element while setting the content. Syntax: To return text content:$(selector).text()To set text content:$(selector).text(content)To set the text content using a function:$(selec 2 min read Difference between html() text() and val() methods in jQuery In this article, we are going to discuss the differences between html(), text(), and val() methods and their usage. 1. jQuery html() method: The html() method is used to set or return the inner HTML of a selected element. It works similarly to innerHTML in normal JavaScript to set or get the content 4 min read What is the difference between parent() and parents() methods in jQuery ? The jQuery parent() and parents() methods return the elements which are ancestors of the DOM. It traverses upwards in the DOM for finding ancestors. In this article, we will learn about the difference between parent() and parents() methods. parent() Method: The parent() method traverse only one leve 4 min read What is the difference between position() and offset() in jQuery ? Both the jQueryUI method the returns the object which contains integer co-ordinate properties of the top and left positions. The positions of top and left coordinates are returned in pixels. Both functions are applied only on visible elements, not on hidden elements. Example: The example gives top a 2 min read What is the difference between every() and some() methods in JavaScript ? In this article, we will see the difference between every() and some() methods in JavaScript. Array.every() methodThe Array.every() method in JavaScript is used to check whether all the elements of the array satisfy the given condition or not. The output will be false if even one value does not sati 3 min read Like