解决IE下file input的onchange事件监听问题

代码示例

<!doctype html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<input type="file" />

<script>
var $ = window.jQuery;

function filechange(){
    alert(this.value);
}

$(function(){
    //IE support this
    if('onpropertychange' in document.documentElement){
       $('input').bind('propertychange', filechange);
    }else{
        $('input').bind('change', filechange);
    }
})
</script>

参考资料

posted @ 2013-05-07 20:48  猫哥_kaiye  阅读(1878)  评论(0)    收藏  举报