我有以下代码可以重置输入文件:
$(this).replaceWith($(this).clone());
但是,我注意到,如果我使用特定的输入文件,则不会处理其事件触发。这是在文件输入更改时处理事件的代码:
$('#frontfile').change(function(){
reader2 = Main.Mod.image_change(this);
reader2.onload = rearImageIsLoaded;
});
问题出在哪里?
我们将非常感谢您的回复...
最佳答案
您可以将 true 传递给 clone method克隆与其关联的处理程序和数据
$(this).replaceWith($(this).clone(true, true));
关于javascript - 重置输入文件时删除事件处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29959461/