I have the following HTML.
<div id="programsData">
<ul id="programsDataItems">
</ul>
</div>
I populate the list using jQuery with this code snippet. Let's say it appends the list items (Item1 and Item2) to the list.
$.each(data, function (i, val) {
$("#programsDataItems").append("<li><a href='#'>" + val.Value + "</a></li>");
})
Here is my function to get the list item clicked on:
$("#programsDataItems").click(function (e) {
var selectedLi = $(this).text;
e.preventDefault();
});
When I click on a list item, the above function returns: Item1Item2. I need to get only one list item. Can someone tell me how to get just the one list item clicked on? Do I need to modify how I am loading the list items?