How to display file name for custom styled input file using jquery?

前端 未结 7 1326
我寻月下人不归
我寻月下人不归 2020-12-02 15:49

I have styled a file input using CSS:

7条回答
  •  不思量自难忘°
    2020-12-02 16:09

    I've had a long crack i hope it helps you may need to style it more to your liking

    HTML

    CSS

    .custom-file-upload {
      border: 1px solid #ccc;
      display: inline-block;
      padding: 6px 12px;
      cursor: pointer;
    }
    
    #uploadFile {
      text-align: center;
      border: none;
      background-color: white;
      color: black;
    }
    

    JavaScript

    document.getElementById("file-upload").onchange = function() {
      document.getElementById("uploadFile").value = this.value;
    };
    

    JSFiddle link:https://jsfiddle.net/kd1brhny/

提交回复
热议问题