onclick event not triggered when onchange triggered right before

前端 未结 3 689
情话喂你
情话喂你 2021-01-14 17:50

i have a funny problem here.

I have a textarea with an onchange event linked to it. Then i have a button linked to an onclick event.

The text being put to th

3条回答
  •  情话喂你
    2021-01-14 18:29

    You need to recheck your assumptions. In your example, alert() interrupts the program flow, breaking handling of onclick. This code (jsfiddle here) demonstrates that onchange does not interfere with onclick by default:

    
    
    

    I had a similar problem, but the actual reason that the onclick event was not handled was that the element being clicked, scrolled down as a result of the onchange handler. When the mouse button was released, the element did not receive a mouseup event and the "click" was interrupted.

提交回复
热议问题