<input name="txt" type="text" id="txt" onchange="txtChange()"/>
< input type="submit" name="Submit" value="点击我,让文本框获取焦点,同时触发onchange事件" onclick="clickMe()"/>
< script>
function clickMe()
{
var o=document.getElementById("txt");
o.focus();
o.value="hello world!";//自动赋值以后文本框已经change,理论上要发生onchange事件
//但是如果不加以下这句是不会触发onchange事件的
o.fireEvent("onchange");
}
function txtChange()
{
alert("同时触发了onchange事件");
}
< /script>