I have this code
$(".delete2").click(function() { $('#load2').fadeIn(); }
I have dynamically added an item using this return
addSubcategory = function(){ sucategorynameval = $("#sucategoryname").val(); categoryId = $("#addcategoryid").val(); $.get("process-add-subcat.php", { "action": "add_subcategory", "sucategoryname": sucategorynameval, "categoryId":categoryId }, function(data){ //$("#main-cat-"+categoryId).load(location.href+"&pageExclusive=1 #main-cat-"+categoryId+">*",""); $("#main-cat-"+categoryId).append(data); $("#addcategoryid").val(''); $("#sucategoryname").val(''); });
The returned data contains delete2 classified element.
How to apply click event to newly added item?
source share