IE8下jquery无法设置textarea的值

clipboard.png

clipboard.png

点击选择文件,选择好文件后,后面的“未选择文件”变成选择文件的文件名,但是IE8无效,求解。。
以下是代码

<div class="fl psr"><a href="javascript:;" class="sui-btn" style=" border-color:#666666;">选择文件</a><input type="file" name="file" id="file" value=""><br/><a href="" style="color:#1d4fe2;" class="ml10 lh20">下载模版</a></div>
                <textarea id="aim" readonly>未选择......文件</textarea>
var file = $('#file'),
        aim = $('#aim');
    file.on('change', function( e ){
        var name = e.currentTarget.files[0].name;
        aim.val( name );    
    });

jquery是jquery-1.8.3.min.js这个版本,不能使用更低版本的,项目要求最低兼容ie8,真的难受

阅读 3.9k
1 个回答

这样IE应该兼容
<script>

 document.getElementById("file").onchange=function(){
    document.getElementById("aim").value= this.value;
 }

</script>

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题