Skip to content

Instantly share code, notes, and snippets.

@Granze
Created March 25, 2012 22:36
Show Gist options
  • Select an option

  • Save Granze/2200450 to your computer and use it in GitHub Desktop.

Select an option

Save Granze/2200450 to your computer and use it in GitHub Desktop.
Find the index of an element in <ul>
$("ul > li").click(function () {
var index = $(this).prevAll().length;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment