<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<title>Title</title>
</head>
<body>
????<form?action=""?method="post"?name="frm">
????????<label?for="username">用戶名:</label>
????????<input?type="text"?name="username"?value=""?id="username"></br>
????????<label?for="password">密 碼:</label>
????????<input?type="password"?name="password"?value=""?id="password"></br>
????????<input?type="submit"?name="submit"?value="Login">
????</form>
????<script>
?var?frmobj=document.getElementsByName("frm");
?var?frmob=document.frm;
?console.log(frmobj);
?console.log(frmob);
?</script>
</body>
</html>這里的document.getElementsByName("frm");和?var?frmob=document.frm;打印出來的分別是NodeList [ form ]<form action="" method="post" name="frm">有什么區(qū)別?實(shí)際操作表單的時候用哪個?
js getElementsByName問題
Ximoo
2018-10-07 10:00:50