I have this switch that people can click to turn something on and off. Most young people know that a single click on a button is sufficient to activate that button. But I’ve seen quite a lot of old people double clicking any kind of button. So the old people will get confused at why the switch turned on and then off immediately, leaving them in the same state in which they started.
<a
id="switch1"
href="#"
onclick="toggle(); return false;"
ondblclick="alert('do not double click')"
>
click here
</a>
So my intention above was for double clicks to only fire ondblclick event, which does not actually toggle the switch. But what’s really happening on a double click is two onclicks are fired, then followed by the ondbclick.
How can I make this do what I intended? I have quite a lot of buttons, so a flexible solution would be best. I’m trying not to acutally go into the toggle function and create a mini state machine… because I have a ton of other functions for which I want to prevent double click.
Thanks