javascript - Event for SELECT onchange with keyboard - Stack Overflow

I have an onchange event on an HTML SELECT control which calls a JavaScript function. This works if I s

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.

Share Improve this question edited Feb 28, 2013 at 13:03 SabreWolfy asked Jan 23, 2012 at 13:41 SabreWolfySabreWolfy 5,54014 gold badges54 silver badges74 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The 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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744743070a4591143.html

相关推荐

  • javascript - Event for SELECT onchange with keyboard - Stack Overflow

    I have an onchange event on an HTML SELECT control which calls a JavaScript function. This works if I s

    8小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信