如果我有以下 HTML
<input type="text" name="Text1" value="MyText" id="Text1"/>
如果我在页面后运行以下 javascript 代码
var text = document.getElementById("Text1");
text.defaultValue = "i am default value";
which sets the defaultValue of the input field I get two different reactions depending on the browser. In IE9, the value is not changed, but default value is changed, which is actually the expected behaviour. In Chrome (and Firefox) both the value and defaultValue are changed. WHY? However if I run this JavaScript
var text = document.getElementById("Text1");
text.value = text.value; // No functional change, however triggers something in the DOM
text.defaultValue = "i am default value";
then it works as expected, that is it is only the defaultValue that is changed in Chrome
Any ideas on why and how to make Chrome (and Firefox) run as IE9 does?