GetPosition 2

By Daniel Burnett on May 9, 2008


This code returns the position of a given element in a given container, relative to other elements of its type. Very useful for finding position indexes of list items, pictures, form items, and more.

Click on a list item below:

  1. This is an ordered list.
  2. Click on any item in the list.
  3. JavaScript can get its position!
  4. Very useful for dynamic lists.

Click on a graphic below (these are in a different container from the ones above):


  • Created by: Daniel Burnett (“IceMetalPunk”)
  • Posted: May 9, 2008

Source Code

Paste this source code into the designated areas.


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document