HTML DOM 輸入文字表單屬性
HTML DOM 輸入文字表單屬性用於返回包含輸入文字域的表單引用。如果輸入文字域不在表單中,它將返回 NULL。該屬性是隻讀的。
語法
以下是輸入文字表單屬性的語法。
textObject.form
示例
讓我們看看一個輸入文字表單屬性的示例 −
<!DOCTYPE html>
<html>
<body>
<h1>Input Text form Property</h1>
<form id="NEW_FORM">
USERNAME: <input type="text" id="TEXT1">
</form>
<p>Get the form id by clicking on the below button</p>
<button type="button" onclick="formId()">GET FORM</button>
<p id="Sample"></p>
<script>
function formId() {
var P=document.getElementById("TEXT1").form.id;
document.getElementById("Sample").innerHTML = "The id of the form containing the text field is: "+P ;
}
</script>
</body>
</html>輸出
將產生以下輸出 −

單擊獲取表單按鈕後 −

廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言
C++
C#
MongoDB
MySQL
Javascript
PHP