下面有一个jquery函数,当上传完成后,它会将文件名存储在一个字符串中,并且它是文本输入中的id。现在在功能的底部,如果用户点击deletevideofile
按钮,那么它就能删除文件名,这很好,但我的问题是如何删除文本输入?我似乎无法删除文本输入。
以下是代码:
function stopVideoUpload(success, videoID, videofilename){
var result = '';
videocounter++;
if (success == 1){
result = '<span class="videomsg'+videocounter+'">The file was uploaded successfully</span>';
$('.listVideo').eq(window.lastUploadVideoIndex).append('<input type="text" name="vidid" value="' + videoID + '" />');
$('.listVideo').eq(window.lastUploadVideoIndex).append('<div>' + htmlEncode(videofilename) + '<button type="button" class="deletefilevideo" video_file_name="' + videofilename + '">Remove</button><br/><hr/></div>'); }
var _videocounter = videocounter;
$('.listVideo').eq(window.lastUploadVideoIndex).find(".deletefilevideo").on("click", function(event) {
var video_file_name = $(this).attr('video_file_name');
jQuery.ajax("deletevideo.php?videofilename=" + video_file_name)
.done(function(data) {
$(".videomsg" + _videocounter).html(data);
});
$(this).parent().remove();
});
return true;
}
答案 0 :(得分:0)
$('.listVideo').eq(window.lastUploadVideoIndex).append('<input type="text" name="vidid" value="' + videoID + '" id="'+ videofilename +'" />');
$('.listVideo').eq(window.lastUploadVideoIndex).append('<div>' + htmlEncode(videofilename) + '<button type="button" class="deletefilevideo" video_file_name="' + videofilename + '">Remove</button><br/><hr/></div>'); }
var video_file_name = $(this).attr('video_file_name');
$('#'+video_file_name).remove();
在您的代码中替换此代码并尝试检查......您是否获得了所需的putput
答案 1 :(得分:0)
你应该尝试这个:
$(this).parent().siblings('input[name="vidid"]').val('').remove();
答案 2 :(得分:0)