HTML DOM Textarea form 属性
htmldomweb developmentfront end technology更新于 2024/5/22 0:44:17
HTML DOM Textarea form 属性返回包含文本区域的表单引用。
语法
以下是语法 −
object.form
让我们看一个 HTML DOM Textarea form 属性的示例:
示例
<!DOCTYPE html>
<html>
<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>
<body>
<h1>DOM Textarea form Property Demo</h1>
<form id="Form 1">
<fieldset>
<legend>Form 1</legend>
<textarea rows="5" cols="20">Hi! I'm a text area element with some dummy text.</textarea>
</fieldset>
</form>
<button onclick="identify()">Identify Textarea Form</button>
<p class="show"></p>
<script>
function identify() {
var formId = document.querySelector("textarea").form.id;
document.querySelector(".show").innerHTML = "Hi! I'm from " + formId;
}
</script>
</body>
</html>
输出

点击"识别文本区域表单"按钮来识别包含文本区域元素的表单。

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

