alternate to onchange event in <input type='file' />

前端 未结 8 1971
青春惊慌失措
青春惊慌失措 2020-12-10 04:04

Seems really a simple thing but can\'t figure it out. I\'ve been using the onchange event on element and it works well. Once the user browses and selects a file, I get the

8条回答
  •  一个人的身影
    2020-12-10 04:19

    function resetFileInput ($element) {
      var clone = $element.clone(false, false);
      $element.replaceWith(clone);
    }
    

    And then use live:

    $('#element_id').live('change', function(){
    ...
    });
    

    Worked well for me!

提交回复
热议问题