<input id='tel' type='text' name='tel' value='hi' /><script>
var input=document.getElementById('tel');
input.mame='telephone';//控制台审查该元素,看到name特性变成了telephone
input.value='123456';//控制台审查该元素,发现value特性还是hi
</script>这是为何? name和value都是input元素的公认特性,为何不能通过修改dom对象的属性来修改value特性?
1 回答

牛奶老哥哥
TA贡献204条经验 获得超92个赞
input.value指的是改变输入域的值,
input.setAttribute('value','123')是改变 input 的 value 属性的值(input默认value)

添加回答
举报
0/150
提交
取消