HTML DOM Input FileUpload type 属性
HTML DOM input FileUpload type 属性返回 HTML 文档中 <input> 元素的 type 属性的值。
语法
语法如下 −
object.type
举例
我们来看看 HTML DOM input 文件上传 type 属性的一个示例 −
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align:center;
background-color:#52B2CF;
color:#fff;
}
.btn{
background-color:coral;
border:none;
height:2rem;
border-radius:50px;
width:60%;
margin:1rem auto;
display:block;
color:#fff;
outline:none;
}
.show{
font-size:2rem;
color:#fff;
font-weight:bold;
}
</style>
</head>
<body>
<h1>DOM fileupload type property example</h1>
<input type = "file" class = "file-upload-btn">
<button onclick="getType()" class="btn">Click me to get value of type
property</button>
<div class="show"></div>
<script>
function getType() {
var fileBtn = document.querySelector(".file-upload-btn");
document.querySelector('.show').innerHTML = fileBtn.type;
}
</script>
</body>
</html>输出
这将生成以下输出 −

现在单击“橙色”按钮可获取 input 文件上传按钮的 type 属性值。

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP