开发者

Change event for input type file not working

Hi I need to get the name of the file the user selects from the input type file control and display it on to the page. The jquery onchange event does not work in ie 8. Can anybody tell me the solution?

// this is my jquery code

$(document).ready(function() 
{
    $('input[type=file]').change(function(){
        var val=$('input[type=file]').val();    
        alert(val);
        $("#textfile").attr("value", val);
        });
}); 

//HTML Code

<input type="file" class="file" name="upload_file" id="UserIcon" /> 
<input type="text" id='textfile' width="100px" />

But in IE After uploading 开发者_C百科i saw that some thing added after file

input name="upload_file" class="file" id="UserIcon" type="file" jQuery15102237614897631498="27" value="C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg"/>


This is not a jQuery problem, but a JavaScript problem. As far as I know IE does not know the onchange event handler. Instead of change, try click.

Getting jQuery to recognise .change() in IE

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜