which event raised when set value of input in javascript

后端 未结 3 1999
-上瘾入骨i
-上瘾入骨i 2021-01-22 01:44

when set value of input in javascript which event raised? i tried these event :(propertychange change keypress paste focus textInput input keyup keydown change) for example:

3条回答
  •  萌比男神i
    2021-01-22 02:35

    When you set the value programmatically no event will be raised. You can raise it yourself though:

    $('input')[0].value = "sd";
    $('input').first().trigger("change");
    

    Or just using jQuery:

    $('input').first().val("sd").trigger("change");
    

提交回复
热议问题