How to rename HTML “browse” button of an input type=file?

前端 未结 10 1519
轻奢々
轻奢々 2020-11-27 15:01

How to rename the browse button as \"Select the file\"? E.g.:


10条回答
  •  春和景丽
    2020-11-27 15:40

    You can do it with a simple css/jq workaround: Create a fake button which triggers the browse button that is hidden.

    HTML

    
    
    

    CSS

    input { display: none }
    

    jQuery

    $( 'button' ).click( function(e) {
        e.preventDefault(); // prevents submitting
        $( 'input' ).trigger( 'click' );
    } );
    

    demo

提交回复
热议问题