未捕获的ReferenceError:未定义removeLine

我正在使用此SO答案中的以下代码,但它确实在这里工作,但当我尝试删除我身边的图像时,我得到:

未捕获的ReferenceError:HTMLSpanElement.onclick中未定义removeLine( https://example.com/test/createst/?myDates=2017&myCountry=Italia:1 )

注意

我需要做的另一点是创建上传图像的预览,我发现以下代码通过询问另一个问题我在哪里实际上有相反的情况,设法有预览而不是删除

var dropZoneId = "drop-zone"; var buttonId = "clickHere"; var mouseOverClass = "mouse-over"; var dropZone = $("#" + dropZoneId); var inputFile = dropZone.find("input"); var finalFiles = {}; $(function() { var ooleft = dropZone.offset().left; var ooright = dropZone.outerWidth() + ooleft; var ootop = dropZone.offset().top; var oobottom = dropZone.outerHeight() + ootop; document.getElementById(dropZoneId).addEventListener("dragover", function(e) { e.preventDefault(); e.stopPropagation(); dropZone.addClass(mouseOverClass); var x = e.pageX; var y = e.pageY; if (!(x  ooright || y  oobottom)) { inputFile.offset({ top: y - 15, left: x - 100 }); } else { inputFile.offset({ top: -400, left: -400 }); } }, true); if (buttonId != "") { var clickZone = $("#" + buttonId); var oleft = clickZone.offset().left; var oright = clickZone.outerWidth() + oleft; var otop = clickZone.offset().top; var obottom = clickZone.outerHeight() + otop; $("#" + buttonId).mousemove(function(e) { var x = e.pageX; var y = e.pageY; if (!(x  oright || y  obottom)) { inputFile.offset({ top: y - 15, left: x - 160 }); } else { inputFile.offset({ top: -400, left: -400 }); } }); } document.getElementById(dropZoneId).addEventListener("drop", function(e) { $("#" + dropZoneId).removeClass(mouseOverClass); }, true); inputFile.on('change', function(e) { finalFiles = {}; $('#filename').html(""); var fileNum = this.files.length, initial = 0, counter = 0; $.each(this.files,function(idx,elm){ finalFiles[idx]=elm; }); for (initial; initial < fileNum; initial++) { counter = counter + 1; $('#filename').append('
' + counter + ' ' + this.files[initial].name + '  
'); } }); }) function removeLine(obj) { inputFile.val(''); var jqObj = $(obj); var container = jqObj.closest('div'); var index = container.attr("id").split('_')[1]; container.remove(); delete finalFiles[index]; //console.log(finalFiles); }
 #drop-zone { width: 100%; min-height: 150px; border: 3px dashed rgba(0, 0, 0, .3); border-radius: 5px; font-family: Arial; text-align: center; position: relative; font-size: 20px; color: #7E7E7E; } #drop-zone input { position: absolute; cursor: pointer; left: 0px; top: 0px; opacity: 0; } /*Important*/ #drop-zone.mouse-over { border: 3px dashed rgba(0, 0, 0, .3); color: #7E7E7E; } /*If you dont want the button*/ #clickHere { display: inline-block; cursor: pointer; color: white; font-size: 17px; width: 150px; border-radius: 4px; background-color: #4679BD; padding: 10px; } #clickHere:hover { background-color: #376199; } #filename { margin-top: 10px; margin-bottom: 10px; font-size: 14px; line-height: 1.5em; } .file-preview { background: #ccc; border: 5px solid #fff; box-shadow: 0 0 4px rgba(0, 0, 0, 0.5); display: inline-block; width: 60px; height: 60px; text-align: center; font-size: 14px; margin-top: 5px; } .closeBtn:hover { color: red; display:inline-block; } } 
   

Drop files here...

or click here..