jQuery trigger file input

后端 未结 21 1887
梦如初夏
梦如初夏 2020-11-22 08:49

Am trying to trigger an upload box (browse button) using jQuery.
The method I have tried now is:

$(\'#fileinput\').trigger(\'click\');   
21条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 09:08

    Based on Guillaume Bodi's answer I did this:

    $('.fileinputbar-button').on('click', function() {
        $('article.project_files > header, article.upload').show();
        $('article.project_files > header, article.upload header').addClass('active');
        $('.file_content, article.upload .content').show();
        $('.fileinput-button input').focus().click();
        $('.fileinput-button').hide();
    });
    

    which means it's hidden to start with and then displayed for the trigger, then hidden again immediately.

提交回复
热议问题