"平变化"事件延迟在IE? (确定与Firefox) [英] "onchange" event delayed in IE? (ok with Firefox)
问题描述
这可能是一个初学者的问题,但我不明白为什么onchange事件是从来没有被IE调用,而它的工作与Firefox好。
< input type =textid =mytextsize =48value =onchange =execute()/>
< button type =buttononclick =execute()> Go< / button>
执行功能在按钮被点击时被调用,但当输入框中的文本被改变。
任何想法?
IE只会触发<$当元素失去焦点的时候c $ c> onchange 事件 - 如果你要在元素或者选项卡之外点击一个不同的元素,那么它应该会触发一次。
您可以使用不同的事件来解决这个问题,例如 onkeypress
。
It might be a beginner question but I can't understand why the onchange event is never called by IE while it works Ok with firefox.
<input type="text" id="mytext" size="48" value="" onchange="execute()"/>
<button type="button" onclick="execute()">Go</button>
The execute function is called when the button is clicked but not when the text in the input box is changed.
Any idea?
IE only fires the onchange
event when the element loses focus - if you were to click outside the element or tab to a different element it should fire then.
You can get around this by using a different event, for example onkeypress
.
这篇关于"平变化"事件延迟在IE? (确定与Firefox)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!