admin管理员组文章数量:1391929
I have an onchange
event on an HTML SELECT control which calls a JavaScript function. This works if I select a new option from the open list with the mouse, or if I drop down the SELECT control and then select an option with the mouse or select with the keyboard and press ENTER.
How can I get the function to run if the SELECT control is NOT open and I simply scroll up or down with the cursor keys through the various options. onblur
does nothing and onkeypress
result in some strange results in which values got out of sync.
I have an onchange
event on an HTML SELECT control which calls a JavaScript function. This works if I select a new option from the open list with the mouse, or if I drop down the SELECT control and then select an option with the mouse or select with the keyboard and press ENTER.
How can I get the function to run if the SELECT control is NOT open and I simply scroll up or down with the cursor keys through the various options. onblur
does nothing and onkeypress
result in some strange results in which values got out of sync.
1 Answer
Reset to default 5The onkeyup
event will solve this:
<select name="theName" id="theID" onchange="javascript:theFunction();" onkeyup="javascript:theFunction();">
<option value="A">Choice A</option>
<option value="B">Choice B</option>
<option value="C">Choice C</option>
</select>
本文标签: javascriptEvent for SELECT onchange with keyboardStack Overflow
版权声明:本文标题:javascript - Event for SELECT onchange with keyboard - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744743069a2622724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论