Sila Khatun Sila Khatun - 3 months ago 5x
jQuery Question

jQuery remove div which added with jQuery

This is capture

I add some div with jQuery, Every div have a cancel button for remove the div.
But div remove button not working.
Here is my div remove code


And here is my full jQuery code

var BaseURL = $(".BaseURL").val();
var fPeople = $('.fPeople').val();
ajax: {
url: ""+ BaseURL +"json/tag",
method: 'post',
triggerLength: 1
onSelect: (function(item){
var aprid = item.value;
var aprname = item.text;
var nappr = " <i class='tagcover'>"+ aprname +" <b class='cursor_pointer text-danger canceltag'>X</b><input type='hidden' name='tag[]' value='"+ aprid +"'></i>";





Use event delegation to attach event to dynamically created element appended to document

// attach event to `.canceltag` parent element
$(".selectedname").on("click", ".canceltag", function() {