HTML DOM Input Hidden type 属性
htmlweb developmentfront end technology更新于 2025/7/1 11:56:17
HTML DOM Input Hidden type 属性返回输入字段类型属性的值。
语法
以下是语法 −
object.type
示例
让我们看一个 HTML DOM Input Hidden type 属性的示例 −
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align:center;
background-color:#F19A3E;
color:#fff;
}
.btn{
background-color:#3C787E;
border:none;
height:2rem;
border-radius:50px;
width:60%;
margin:1rem auto;
display:block;
color:#fff;
outline:none;
}
.show{
color:#fff;
font-size:1.2rem;
font-weight:600;
}
</style>
</head>
<body>
<h1>DOM Hidden type Property Demo</h1>
Enter your Name:<input type="hidden" class="input-field">
<button onclick="getType()" class="btn">Click to get above input type</button>
<div class="show"></div>
<script>
function getType() {
var inputField = document.querySelector(".input-field");
var msgDiv = document.querySelector(".show");
msgDiv.innerHTML = "type = " + inputField.type;
}
</script>
</body>
</html>
输出
这将产生以下输出 −

点击“点击获取上述输入类型”按钮获取隐藏输入字段的类型属性值。

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

