Replace input type=file by an image

后端 未结 13 2095
感动是毒
感动是毒 2020-12-02 04:13

Like a lot of people, I\'d like to customize the ugly input type=file, and I know that it can\'t be done without some hacks and/or javascript. But,

13条回答
  •  长情又很酷
    2020-12-02 04:35

    You can put an image instead, and do it like this:

    HTML:

    
    
    

    JQuery:

    $("#upfile1").click(function () {
        $("#file1").trigger('click');
    });
    

    CAVEAT: In IE9 and IE10 if you trigger the onclick in a file input via javascript the form gets flagged as 'dangerous' and cannot be submmited with javascript, no sure if it can be submitted traditionaly.

提交回复
热议问题