How to change first and last elements of a list using jQuery?

To change the first and last elements of a list use the eq() method.

Example

You can try to run the following code to change first and last elements of a list using jQuery:







This year's ranking:

     
  • India
  •  
  • US
  •  
  • UK

Last year's ranking:

     
  • India
  •  
  • US
  •  
  • UK
Updated on: 2026-03-11T23:14:17+05:30

826 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements