I have below js which the event is not fire after ajax append the content
$(".item").mouseenter(function(){ $(this).children('.delete').show(); });
$(".item").mouseleave(function(){ $(this).children('.delete').hide(); });
$(".delete").click(function(){
$(this).parent().hide(); });
$("#add").click(function(){
action = 'addItem';
$.ajax({
type: "POST",
url: "/echo/json/",
data: 'action='+action,
cache: false,
success: function(json){
$(".main").append('<div class="item"><div class="content"> content new </div><div class="delete"> delete </div></div>');
}
});
});
Please check out the jsfiddle at http://jsfiddle.net/3j5L2/19/
How do I ensure no matter how many item I added in, the mouseenter and mouseleave event get fired?