我需要使用 html5 File API 来获取在输入文件元素中选择的文件数量并在另一个元素中设置值。
HTML
<div class="form-row">
<label>Main Image</label>
<div class="form-text">None Selected</div>
<input type="file" class="txtbox" name="proImage" id="proImage" value="" />
</div>
jQuery
$('input[type=file]').change(function () {
$fileCount = $(this).files.length;
$(this).parent('.form-row').find('.form-text').html($fileCount + 'Selected');
})
有人知道我要去哪里错了吗?所有帮助表示赞赏