HTML DOM 輸入 FileUpload value 屬性
HTML DOM input FileUpload value 屬性會返回檔案上傳輸入按鈕 value 屬性的內容。
語法
以下是語法 -
object.value
示例
讓我們來看一個 input FileUpload value 屬性的示例 -
<!DOCTYPE html> <html> <head> <title>HTML DOM name Property</title> <style> body{ background-color:#397367; color:#fff; padding:20px; } .btn{ display:block; background-color:#22223B; color:#fff; border:none; padding:0.5rem; border-radius:50px; width:80%; margin:10px; } .show-value{ font-weight:bold; font-size:1.4rem; color:#fff; } </style> </head> <body> <h1>FileUpload value Property Example</h1> <p>Please Select a File!</p> <input type="file"> <button onclick="getValue()" class="btn">Get File Upload Button Value</button> <div class="show-value"></div> <script> function getValue() { var chooseFileBtn= document.querySelector("input"); document.querySelector(".show-value").innerHTML ="Value = " + chooseFileBtn.value; } </script> </body> </html>
輸出
這將生成以下輸出 -
單擊“獲取檔案上傳按鈕值”按鈕以獲取 input 檔案上傳按鈕的 value 屬性內容。
廣告