Any alternative to jQuery change() to detect when user selects new file via dialog box in IE8?

前端 未结 3 484
不知归路
不知归路 2020-12-11 07:56

I am unable to detect when input type=\"file\" changes its value after user selects file and the dialog box closes.

$(\'.myInput\').change(function(){
    a         


        
3条回答
  •  一个人的身影
    2020-12-11 08:31

    Edit - Nick is right, it's fixed in 1.4.2. http://jsfiddle.net/7wR2L/

    You can detect click and keep track of it's last value. Something like..

    $('.myInput').click(function() {
       var $file = $(this);
       if( $file.val() != $file.data('lastVal') ) {
         // different
       }
       $file.data('lastVal', $file.val() );
    });
    

提交回复
热议问题