繁体   English   中英

重置输入文件时删除事件处理程序

[英]Event handlers removed when resetting input file

我有以下代码重置输入文件:

$(this).replaceWith($(this).clone());

但是,我注意到,如果使用特定的输入文件,则不会处理其事件触发。 因此,此代码用于在更改文件输入时处理事件:

$('#frontfile').change(function(){
        reader2 = Main.Mod.image_change(this);
        reader2.onload = rearImageIsLoaded;
    });

似乎是什么问题?

您的回复将不胜感激...

您可以将true传递给clone方法来克隆处理程序和与其关联的数据

$(this).replaceWith($(this).clone(true, true));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM