Very new to jQuery, if dupe question sorry at this point not even sure I am using correct verbiage.
I need to add a li item to a ul based on a click event of a ListBox (user selects text and a new li is added with the selected text). And I need to add a icon, label and input on the li item. The icon needs to be a 'remove' icon.
How can I wire up the function to remove the newly added li item via jQuery?
Here is what I have tried;
$(function() {
function addSelectedWordCriteria() {
var selectedWord = $("#wsWords").val();
$("#wsCriteriaList").append("<li><a href='#' class='wsCriteriaRemove'><span class='ui-icon ui-icon-circle-close'/></a><em class='wsFilteredWord'>" + selectedWord + "</em><input type='textbox' maxlength='200' class='wsFilteredWords'/></li>");
$("#wsCriteriaList a:last").bind("click", "removeSelectedWordCriteria");
};
function removeSelectedWordCriteria() {
$("#wsCriteriaList").selected().remove();
}
})
<%= Html.ListBox("wsWords", ViewData["Words"] as IEnumerable<SelectListItem>) %>
<ul id="wsCriteriaList">
</ul>
Thanks for any suggestions.