property和attribute的区别---value

从网上看到很多写关于input的value属性,写的setAttribute可以影响DOM的property的value,在实践中我发现不同现象,

在页面初始化后,用setAttribute对value进行设置,确实会出现对property有影响。

但是我发现使用 ele.value 或者 ele['value'] 又或者 “在输入框中手动输入内容  设置对象的property之后,setAttribute的设置将会对property失效

 

所以,经实践表明,setAttribute('value', value) 不是绝对的能同时修改 property的value 值。当 ele.value 或者 ele['value'] 又或者 在输入框中手动输入内容  设置对象的property的value值后,setAttribute将不能再控制property的value值。

 

posted @ 2018-06-05 17:12  胖了个胖胖  阅读(215)  评论(0编辑  收藏  举报