Javascript 的 property 和 attribute 。
2015-04-03 12:58
309 查看
http://stackoverflow.com/questions/17494432/javascript-element-value-vs-element-getattributevalue
http://my.oschina.net/u/1163293/blog/268262
This attribute's value, when read, is used to fill the element'svalueproperty.
That property is what you get afterwards when you useElement.valueand that's what changed by the user or most JavaScript functions. The attribute isn't changed when the user changes the value through the interface.
In short, you almost always want to useElement.valueand almost neverElement.getAttribute("value").
“.”出来的是 property ,“.getAttribute(...)”出来的是 attribute ;
attribute -> property :同步。
property -> attribute :某些浏览器可能会对标准 property / attribute 做反向同步,某些浏览器可能全同步,某些浏览器可能不同不。
等待 Firefox 和 IE 验证。
大致如此,但不绝对,详见 http://www.mxgw.info/coding/javascript-attribute-property.html 。
http://my.oschina.net/u/1163293/blog/268262
This attribute's value, when read, is used to fill the element'svalueproperty.
That property is what you get afterwards when you useElement.valueand that's what changed by the user or most JavaScript functions. The attribute isn't changed when the user changes the value through the interface.
In short, you almost always want to useElement.valueand almost neverElement.getAttribute("value").
“.”出来的是 property ,“.getAttribute(...)”出来的是 attribute ;
attribute -> property :同步。
property -> attribute :某些浏览器可能会对标准 property / attribute 做反向同步,某些浏览器可能全同步,某些浏览器可能不同不。
等待 Firefox 和 IE 验证。
大致如此,但不绝对,详见 http://www.mxgw.info/coding/javascript-attribute-property.html 。
相关文章推荐
- JavaScript中的property和attribute
- JavaScript中的attribute和property
- Javascript中Property和Attribute的区别
- javascript中attribute和property的区别详解
- HTML中的attribute属性和JavaScript中的property属性的详解以及区别
- JavaScript中的property和attribute介绍
- javascript中property与attribute的区别
- javascript之attribute 和 property
- 基于JavaScript分析property 和 attribute
- JavaScript特性(attribute)、属性(property)和样式(style)
- JavaScript 中 Property 和 Attribute 的区别详解
- javascript中的property和attribute
- JavaScript特性(attribute)、属性(property)和样式(style)
- JavaScript 中 Property 和 Attribute 的区别详解
- javascript中attribute和property的区别详解 3ff0
- javascript中attribute和property的区别详解
- javascript中attribute和property的区别详解
- JavaScript 中 Property 和 Attribute 的区别详解
- javascript中attribute和property的区别详解
- javascript中attribute与property 的区别