propetype和attrabute- property是DOM中的属性,是JavaScript里的对象;
- attribute是HTML标签上的特性,它的值只能够是字符串;
Attribute就是dom节点自带的属性,
而Property是这个DOM元素作为对象,其附加的内容,
attribure中的属性 也是一个 attr类对象
打印 attribut中的属性时,会获取到属性名+值得字符串
console.log(in1.attibutes.title1); // title1="title1"
property 变化时 attribute 不变
attribute变化时 property 改变
<input class="input1">
input.class='llll'
console.dir(input)//property llll; attribute: input1
attribute 赋值为字符串
他会映射到property 上,在属性值为布尔值时,应该修改property
<input id="input" type="checkbox" checked >
input.setAttribute('checked', false)
console.log(input.checked)// 'false' 这就是错误的示范
默认property属性优先
<input type="checkbox" checked id="input">
console.log(input.attributes.checked) // checked = ""
console.log(input.checked)// true