Skip to content

Instantly share code, notes, and snippets.

Created May 7, 2016 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9438f696f90a62d7fadd2eb1d047414a to your computer and use it in GitHub Desktop.
Save anonymous/9438f696f90a62d7fadd2eb1d047414a to your computer and use it in GitHub Desktop.
$('#indexList').children().click(function () {
// get the id of the clicked object
var myIndex = $(this).attr('id');
// pass the id into custom function which will return the index of the item
var itemIndex = getIndexOfItemInList(myIndex);
// alert is displaying the item index
alert(itemIndex);
// THIS IS NOT WORKING
$('#itemResult').text('The index of the item is: ' + itemIndex);
});
<!-- HTML SNIPPET-->
<p id="#itemResult">something</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment