我尝试做上传系统并使用Uploadify。我有 onComplete 函数,可以附加图像并删除按钮。每个图像都有自己的删除按钮,但我无法使其仅删除其图像。请帮助这是我所拥有的代码。谢谢。
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();
});
}
最佳答案
尝试选择previous图像。也就是说,在单击的 div 之前:
$(this).prev("img").andSelf().remove();
关于jQuery 逐个删除元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8520583/