
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How jQuery eq() Method Works
If you want to return an element with a definite index number of the selected elements, then use the eq() method. The first element has index 0, the second element has index 1, etc. Yes, the index number starts at 0.
Example
You can try to run the following code to learn how to work with jQuery.eq() method,
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").eq(3).css("background-color", "gray"); }); </script> </head> <body> <h1>Tutorialspoint</h1> <p>Free Learning</p> <p>Free Text Tutorials</p> <p>Free Video Tutorials</p> <p>Tutor Connect</p> </body> </html>
Advertisements