Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$('#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