jQuery : eq() vs get()

前端 未结 8 1214
挽巷
挽巷 2020-11-28 03:50

I\'m new to jQuery, and I\'m wondering what the difference is between jQuery\'s get() and eq() functions. I may misunderstand what the get()

8条回答
  •  独厮守ぢ
    2020-11-28 04:35

    jQuery eq() method selects a HTML element with a specific index number.

    Here is an example of that

    
      
    $( "body" ).find( "div" ).eq( 2 ).addClass( "red" ); // it finds the second div in the html body and change it to red color.

    Source: http://www.snoopcode.com/JQuery/jquery-eq-selector

提交回复
热议问题