Styling an input type=“file” button

后端 未结 30 1734
终归单人心
终归单人心 2020-11-21 11:50

How do you style an input type=\"file\" button?

30条回答
  •  星月不相逢
    2020-11-21 12:10

    Hide it with css and use a custom button with $(selector).click() to activate the the browse button. then set an interval to check the value of the file input type. the interval can display the value for the user so the user can see whats getting uploaded. the interval will clear when the form is submitted [EDIT] Sorry i have been very busy was meaning to update this post, here is an example

    $(window).load(function () {
        var intervalFunc = function () {
            $('#file-name').html($('#file-type').val());
        };
        $('#browse-click').on('click', function () { // use .live() for older versions of jQuery
            $('#file-type').click();
            setInterval(intervalFunc, 1);
            return false;
        });
    });
    

提交回复
热议问题