Solve IE7 bug “input type=file” onchange fire twice?

こ雲淡風輕ζ 提交于 2019-11-30 14:57:05

This is what I've made after some hard hours of "brain storming" :

$('input:file').click(
    function(){
         $(this).one(
              'change',
              function(){ alert(1) /*do stuff here*/ }
         )
    }
)

Each time user click the input to choose file, we bind the event "change" one time with it. So the event fires exactly once everytime user want to pick a file.

And thanks god it works ! Thank you all.

I would simply unbind the trigger once your function has ran

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!