gpt4 book ai didi

javascript - 在 ('change' 上)未触发

转载 作者:行者123 更新时间:2023-12-01 04:03:29 25 4
gpt4 key购买 nike

我正在动态生成类型文件的输入字段。但是当我尝试获取其触发事件时,什么也没有发生。

下面是动态输入文件

<div id="documentlist" class="col-lg-12">
<div class="input-group">
<div class="fileinput fileinput-exists" data-provides="fileinput">
<span class="btn btn-primary btn-file m-r-10 waves-effect">
<span class="fileinput-new">Upload Your </span>
<span class="fileinput-exists">Document</span>
<input type="hidden" value="" name="">
<input id="0" class="selectdocument" type="file" name="..." multiple>
</span>
<span id="form_f" class="fileinput-filename"></span>
<a href="#" class="close fileinput-exists" data-dismiss="fileinput">×</a>
</div>
</div>
</div>

我的事件处理程序

 // Select Document Form 
$('#documentlist').on('change', '.selectdocument', function () {
alert(this.id);
});

最佳答案

select 元素使用 change,对 input 元素使用 input

$('#documentlist').on('input', '.selectdocument', function () {
alert($(this).closest('.col-lg-12').attr('id'));
});

关于javascript - 在 ('change' 上)未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42001469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com