您的位置:首页 > Web前端 > JavaScript

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: