onclick event not triggered when onchange triggered right before

前端 未结 3 683
情话喂你
情话喂你 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:39

    try this to add event listener to components

    document.getElementsByTagName("textarea")[0].addEventListener("change", function(){
        alert( 'textarea');
    });
    
    document.getElementsByTagName("button")[0].addEventListener("click", function(){
        alert( 'button');
    });
    

    if Ids are defined then use getElementById().

提交回复
热议问题