Jquery HTML5获取更改时的输入文件计数

Jquery HTML5获取更改时的输入文件计数,jquery,html,Jquery,Html,我需要使用html5文件API来获取输入文件元素中选择的文件数量,并在另一个元素中设置值 HTML 有人知道我哪里出错了吗?所有帮助文件都不是jQuery对象的属性 更改此项: $fileCount = $(this).files.length; 致: 您还可以缩小选择器: $('input[type=file]').change(function () { fileCount = this.files.length; $(this).prev().text(fileCount

我需要使用html5文件API来获取输入文件元素中选择的文件数量,并在另一个元素中设置值

HTML


有人知道我哪里出错了吗?所有帮助文件都不是jQuery对象的属性

更改此项:

$fileCount = $(this).files.length;
致:

您还可以缩小选择器:

$('input[type=file]').change(function () {
    fileCount = this.files.length;
    $(this).prev().text(fileCount + 'Selected');
})

aha,原来的脚本就是这么说的,但因为我在jquery中这样做,所以我想我需要在括号内使用它。干杯。还可以在输入文件元素上使用
multiple=“multiple”
属性来选择多个文件。
$fileCount = $(this).files.length;
$fileCount = this.files.length;
$('input[type=file]').change(function () {
    fileCount = this.files.length;
    $(this).prev().text(fileCount + 'Selected');
})