HTML DOM Input FileUpload value 属性
htmlweb developmentfront end technology更新于 2025/6/28 19:24:17
HTML DOM Input FileUpload value 属性返回文件上传输入按钮的 value 属性的内容。
语法
以下是语法 −
object.value
示例
让我们看一个输入 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>
输出
这将产生以下输出 −

点击“获取文件上传按钮值”按钮,获取输入文件上传按钮的value属性内容。

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

