javascript event not triggered if the change origin is not from the html?

后端 未结 2 1069
盖世英雄少女心
盖世英雄少女心 2021-01-27 19:01


I am trying to understand why the change event in the following example is not triggered (I\'ll show exactly where).

I have a checkbox, lets call it \'mainCheckbox

2条回答
  •  生来不讨喜
    2021-01-27 19:39

    Onchange event is fired when the element loses focus. Since you are changing the value programmatically, the element you are changing never loses focus. You may wish to check the oninput event.

提交回复
热议问题