如何使用JavaScript在文档中查找第一个表单的名称?
要获取文档中第一个表单的名称,请在表单属性中使用。您可以尝试运行以下代码以显示名称-
示例
<!DOCTYPE html>
<html>
<body>
<form name ="formOne">
Name: <input type="text" name="my_name" value="Amit">
Subject: <input type="text" name="my_subject" value="Java">
<input type="submit" value="Submit">
</form>
<form name ="formTwo">
</form>
<script>
var val = document.forms.length;
document.write("<br>Number of forms in the document: "+val);
document.write("<br>Name of the first form: "+document.forms[0].name)
</script>
</body>
</html>热门推荐
10 小学同学简短祝福语
11 奶茶店新年祝福语简短
12 闺蜜小孩祝福语简短
13 简短搞笑蛋糕生日祝福语
14 康复儿童六一祝福语简短
15 早上祝福语简短句子
16 生日祝福语 男性简短独特
17 升班祝福语简短10字
18 文案生日祝福语高级简短