我无法确定Element.setAttribute(String name, String value)
和Element.setPropertyString(String name, String value)
之间的差异。有区别吗?当尝试在文本输入上设置占位符时,哪个更适合?我一直在做getElement().setPropertyString("placeholder", "this is a placeholder");
,它的工作原理,但它是适当的方式来做到这一点?GWT元素setAttribute vs setPropertyString
在documentation for DOM,setAttribute(Element, String, String)
已弃用,表示使用“更恰当地命名为setElementProperty(Element, String, String)
”。这是否意味着应该使用Element
的同名命名方法?
根据GWT 2中的Javadoc。4,'getAttribute'“返回:Attr的值为一个字符串,或者是空字符串,如果该属性没有指定或默认值”,不是null,但不影响其余的答案。 +1 – 2011-12-21 15:07:29
此外,这是如何影响属性/属性的移除?例如,有一个'removeAttribute()',但没有'removeProperty()'。假设我有''并且想要移除'max'限制。这将如何实现? – 2011-12-21 15:15:38
将其设置为可以移除约束的任何值,例如空字符串(也可以尝试'null')。请参阅http://dev.w3.org/html5/spec/common-input-element-attributes.html#the-min-and-max-attributes和http://dev.w3.org/html5/spec/states -of-的型attribute.html#号态型数 – 2011-12-21 16:54:46