jQuery change method on input type=“file”

后端 未结 3 691
北荒
北荒 2020-12-02 11:56

I\'m trying to embrace jQuery 100% with it\'s simple and elegant API but I\'ve run into an inconsistency between the API and straight-up HTML that I can\'t quite figure out.

3条回答
  •  暖寄归人
    2020-12-02 12:18

    is the ajax uploader refreshing your input element? if so you should consider using .live() method.

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

    update:

    from jQuery 1.7+ you should use now .on()

     $(parent_element_selector_here or document ).on('change','#imageFile' , function(){ uploadFile(); });
    

提交回复
热议问题