$(".spanCont:first .collection_shop").on("click",function(){
var current_item = $(this);
$.ajax({
url: "ajax/abc.php",
type: "POST",
dataType: 'html',
data: {collection_id: current_item.attr("value")},
beforeSend: function(xhr) {
current_item.replaceWith("<div id='temp_div'></div>");
}
}).done(function(data){
$(".spanCont:first .span-2, .spanCont:first input").remove();
$("#temp_div").replaceWith(data);
});
});
This code should work for all static and dynamic click of elements with class .collection_shop but its only working for static elements.