Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Method eq() in jquery

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 315
    Comment on it

    The eq ( index ) method reduces the set of matched elements to a single element or we can say that find the element that matches or equals the index provided.

    Here is the simple syntax to use this method:

    selector.eq ( index )

    index: This is the position of the element in the set of matched elements, starting at 0 and going to length 1,2,3...or -1,-2,-3....

    In mathematice we studied the set of integers (....-3,-2,-1,0,1,2,3....) in it there are positive and negative integers including 0. When we make index on many div (s) and li (s) we should understand integers.we can take positive integer like 0,1,2,3... and negative integers like -1,-2,-3...

    Following is a simple example which adds the color to fouth list item. We index on li of number 4 will be yellow in color. So we take index eq(3) because integers starts for 0,1,2,3,4.It means the 4th element will be coloured in yellow. or Method reduces three elements (0,1,2,3) and 4th element is coloured.


     <!DOCTYPE html>
       <link href="style.css" type="text/css" rel="stylesheet" />
       <script type="text/javascript" 
       <script type="text/javascript" language="javascript">
             $( "body" ).find( "div" ).eq( 3 ).addClass( "yellow" );       


            font:14px/1 arial,helvetica,sans-serif;
         div {
        width: 20px;
        height: 20px;
        margin: 10px;
        float: left;
        border: 3px solid red;
        .yellow {
        background: yellow;
    Method eq() in jquery

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: