我正在检索referenceError stating: value is not defined
。我试图将Remove
按钮设置为值,以便删除与该值关联的文本输入。但我不知道如何设置value
以修复错误,因为var value=''
不起作用。我想将value
设置为什么?
以下是代码:
function stopImageUpload(success, imageID, imagefilename){
var result = '';
imagecounter++;
if (success == 1){
result = '<span class="imagemsg'+imagecounter+'">The file was uploaded successfully</span>';
$('.hiddenimg').eq(window.lastUploadImageIndex).append('<input type="text" name="imgid[]" id="'+imageID+'" value="' + imageID + '" />');
$('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" data-imageID="'+imageID+'" data-image_file_name="' + imagefilename + '" value="'+imageID+'">Remove</button><br/><hr/></div>');
}
var _imagecounter = imagecounter;
$('.listImage').eq(window.lastUploadImageIndex).find(".deletefileimage").on("click", function(event) {
jQuery.ajax("deleteimage.php?imagefilename=" + $(this).attr('data-image_file_name')).done(function(data) {
$(".imagemsg" + _imagecounter).html(data);
});
var buttonid = $(this).attr(value);
$(this).parent().remove();
$("#"+ buttonid +"").remove();
});
return true;
}
答案 0 :(得分:0)
更改
var buttonid = $(this).attr(value);
到
var buttonid = $(this).attr('value');
或将值初始化为某个属性名称。
答案 1 :(得分:0)
好像你需要
var buttonid = $(this).attr('value');
或value
是未定义的变量