我具有以下输入文件标签:
<input type="file" id="handlerxhr1" />
在mozilla中,当我运行以下jQuery代码时:
var input = $('#handlerxhr1')[0];
$('#upload').click(function() {
alert(input.files[0]);
});
我得到答复:[目标文件](很好)。
但是在IE中我得到'input.files.0未定义'
我在做什么错?
这似乎足够好...
$(function() {
var input = $('#handlerxhr1')[0];
$('#upload').click(function() {
alert(input);
});
});
虽然不确定您是否遵循过这样的方法:
$(function() {
var input = $('#handlerxhr1')[0];
$('#upload').click(function() {
var x = $('input[type=file]:eq(0)');
alert(x);
});
});
IE不支持.files [0]属性,而FF支持。有关更多详细信息,请参见http://www.w3.org/TR/FileAPI/。