修改input標籤type=file型別按鈕的值

Zhuo_chao發表於2020-11-17

 html程式碼如下:

<input type= "file"  id= "file"  name= "file"  style= "display:none"  onchange= "changeAgentContent()"  />
<input type= "text"  value= ""  disabled id= "inputFileAgent"  />
<input type= "button"  onclick= "document.getElementById('file').click()"  th:value="檔案上傳"  />

js:

function  changeAgentContent(){
   document.getElementById( "inputFileAgent" ).value = document.getElementById( "file" ).value;
}

效果圖:

相關文章