<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!--name属性不是所有元素都有,只有一些特定元素才有,表单,表单内的元素,图像,iframe-->
<form name="login">
<input type="text" name="uesername" />
<input type="password" name="password" />
<button name="button">提交</button>
</form>
</body>
<script>
// getElementsByName()返回的是一个节点列表数组,NodeList
var login = document.getElementsByName('login')[0]
console.log(login)
login.style.background = 'pink'
//可以把name属性当成document对象的属性使用
var login1 = document.login;
console.log(login1)
login1.style.background = 'yellow'
</script>
</html>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!