HTML DOM Input Hidden 表單屬性
HTML DOM input hidden form 屬性返回包含 HTML 文件中隱藏 input 域的表單的引用。
語法
以下是語法 −
object.form
示例
我們來看一個 HTML DOM input hidden form 屬性的示例 −
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align:center;
background-color:#363946;
color:#fff;
}
form{
margin:2.5rem auto;
}
button{
background-color:#db133a;
border:none;
cursor:pointer;
padding:8px 16px;
color:#fff;
border-radius:5px;
font-size:1.05rem;
}
.show{
font-weight:bold;
font-size:1.4rem;
}
</style>
</head>
<body>
<h1>form Property Demo</h1>
<form id="Form 1">
<fieldset>
<legend>Form 1</legend>
Here is hidden input field: <input type="hidden" class="hiddenField">
</fieldset>
</form>
<button onclick="identify()">Identify Hidden Input Field</button>
<p class="show"></p>
<script>
function identify() {
var formId = document.querySelector(".hiddenField").form.id;
document.querySelector(".show").innerHTML = "Hi! I'm from " + formId;
}
</script>
</body>
</html>輸出
這將產生以下輸出 −

單擊“識別隱藏輸入欄位”按鈕以識別包含隱藏輸入欄位的表單。

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP