我有一个下拉列表。我正在使用此下拉列表的 onchange
事件在下面的文本框中显示一些文本。
它完全没问题,但我想做这样的事情:---
If user click on the drop down then the whole list will be populated. right.. Now if he is trying to choose the value from the list using up/down arrow button of the key board I want to fire the event at that time. How can I do this?
Onchange
不适用于此目的。
最佳答案
你可以这样做:
<script type="text/javascript">
function change(value){
alert("key pressed "+value)
}
</script>
<select name="k" onkeypress="change(this.value)">
<option value="acb">ABC</option>
<option value="def">DEF</option>
</select>
关于javascript - Dropdownlist的Onchange事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2469181/