Reputation: 21
I try to do upload sistem and use Uploadify. I have onComplete function where apend images and remove buttons. Every image have own remove button, but I can't make it to remove just its image. Please help here is the code what I have. Thanks.
enter code here
'onComplete' : function(event, ID, fileObj, response, data) {
$('#inner2').append('<img id="img" src="'+fileObj.filePath+'" width="100" height="100" /><div id="remove-btn" ><span>Remove Image</span></div>');
$("#remove-btn").live('click',function() {
$(this).parent().remove();
});
}
Upvotes: 2
Views: 742
Reputation: 342795
Try selecting the previous image. That is, previous to the clicked div:
$(this).prev("img").andSelf().remove();
Upvotes: 1
Reputation: 1671
$(this).prev().remove();
$(this).remove();
As i guess you also want to remove the button as it is for an image that isnt there anymore.
Or you could wrap the image and button in a div then your .parent() is fine.
Upvotes: 0