哪个HTMLElement属性更改生成DOMAttrModified? [英] Which HTMLElement property change generates DOMAttrModified?
问题描述
我有以下测试case:
var elem = document.createElement('input');
document.body.appendChild(elem);
elem.id ='inputId'; //触发DOMAttrModified
elem.type ='text'; //触发DOMAttrModified
elem.value ='inputValue'; //不会触发DOMAttrModified
elem.lang ='en'; //触发DOMAttrModified
如果将elem.value更改为elem.defaultValue,则DOMAttrModified会被触发。是否有一个全面的清单?到目前为止,我已经找到HTMLInputElement的值和检查和HTMLOptionElement的选择属性不会引发DOMAttrModified。有没有其他的?
在 DOMAttrModified视觉属性似乎并不完全正确,因为价值也是一个属性。
谢谢,
Sunil
defaultValue
没有。 DOMAttrModified
会在标记属性发生变化时触发,所以 setAttribute
/ removeAttribute
调用以及任何改变属性的属性集。 I have a question about DOMAttrModified. Which changes to an HTML Element properties triggers the DOMAttrModified event (specifically interested in Firefox, but an answer that applies to other browsers might suffice too)?
I have the following test case :
var elem = document.createElement('input');
document.body.appendChild(elem);
elem.id = 'inputId'; // triggers DOMAttrModified
elem.type = 'text'; // triggers DOMAttrModified
elem.value = 'inputValue'; // DOES NOT trigger DOMAttrModified
elem.lang = 'en'; // triggers DOMAttrModified
If I change elem.value to elem.defaultValue, then a DOMAttrModified does get triggered. Is there a comprehensive list somewhere? So far I have found HTMLInputElement's 'value' and 'checked' and HTMLOptionElement's 'selected' property not trigerring DOMAttrModified. Are there any other?
The answer at DOMAttrModified visual attributes does NOT seem to be completely correct, as 'value' is also an attribute.
Thanks, Sunil
The DOM value
property doesn't change the HTML value
markup attribute. The DOM defaultValue
does. DOMAttrModified
fires when markup attributes change, so on setAttribute
/removeAttribute
calls and on any property set that changes an attribute.
这篇关于哪个HTMLElement属性更改生成DOMAttrModified?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!