IE输入文件属性未定义 [英] IE input file attribute is undefined

查看:91
本文介绍了IE输入文件属性未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下输入文件标签:

I have the following input file tag:

<input type="file" id="handlerxhr1" />

在mozilla中,当我运行以下jQuery代码时:

In mozilla when I run the following jQuery code:

var input = $('#handlerxhr1')[0];
        $('#upload').click(function() {
            alert(input.files[0]);

        });

我得到答复:[目标文件](很好).

I get response: [object File] (which is good).

但是在IE中,我得到"input.files.0未定义"

But in IE I get 'input.files.0 is undefined'

我在做什么错了?

推荐答案

这似乎已经足够好了...

This seems good enough...

$(function() {
    var input = $('#handlerxhr1')[0];         
    $('#upload').click(function() {             
        alert(input);          
    }); 
});

虽然不确定您是否遵循过这样的方法:

Not sure if your were after something like this though:

$(function() {
    var input = $('#handlerxhr1')[0];         
    $('#upload').click(function() {             
        var x = $('input[type=file]:eq(0)');
        alert(x);
    }); 
});

这篇关于IE输入文件属性未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆