I am trying to accomplish delete in page which is filled with data by ajax call. my page has this before data is loaded:
Use something like this to call dynamically added class
$('.class').live("click", function(){
$('#id').remove();
});
Try $(e.target).remove()
,
$("#ShowSelectedCategories").click(function(e){
$(e.target).remove();
e.preventDefault();
});
If you want to delete element with class DeleteCat within span with id ShowSelectedCategories then you can do it like this,
$("#ShowSelectedCategories").on("click", "DeleteCat" function(e){
$(this).remove();
e.preventDefault();
});
$('#ShowSelectedCategories').on('click', '.DeleteCat', function(e){
$(this).remove();
e.preventDefault();
});
http://jsfiddle.net/Dj5NQ/