多次选择同一个选项/onchange 不改变 [英] Select the same option multiple times / onchange without changing

查看:35
本文介绍了多次选择同一个选项/onchange 不改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择,每次选择一个选项时我都需要触发一些 js,即使它已经被选择.示例:

I have a select, and I need to fire some js each time an option is selected, even if it is already selected. Example:

<select id="select_one">
    <option value="">Choose One...</option
    <option value="one">One</option>
    <option value="two">Two</option>
</select>

如果有人选择一",我想触发 functionOne().但是,虽然选择了一",但如果用户再次选择一",我想再次触发 functionOne().所以,这意味着 onChange 将不起作用,因为选择没有改变.

If someone selects "one" I want to fire functionOne(). But, while "one" is selected, if the user selects "one" again I want to fire functionOne() again. So, that means onChange won't work, since the selection isn't changing.

有人有什么想法吗?

推荐答案

与当前的一些答案相反,您实际上并没有在

Contrary to some of the current answers, you don't actually get a click event on <option> in IE.

检测已选择的选项被点击的情况的唯一可靠方法是将 onclick 处理程序放在

发送“验证码”获取 | 15天全站免登陆