本文介绍了防止选择下拉菜单打开但允许其事件触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法可以捕获 html 选择事件,并阻止 html 选择下拉菜单打开?(禁用 html select 被排除,因为事件也将被禁用.)
Is there any way I can trap html select events, and prevent the html select dropdown to open? (Disabling html select is ruled out since the events will be disabled too.)
推荐答案
我怀疑这实际上会阻止它打开,但它会确保 DropDown 始终保持相同的值:
I doubt this will actually prevent it from opening, but it will ensure that the DropDown will always maintain the same value:
<select name="theselect" onchange="this.selectedIndex = 1;">
<option value="Red">Red</option>
<option value="Green" selected="selected">Green</option>
<option value="Blue">Blue</option>
</select>
这篇关于防止选择下拉菜单打开但允许其事件触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!