Why does the jquery change event not trigger when I set the value of a select using val()?

后端 未结 9 951
猫巷女王i
猫巷女王i 2020-11-22 09:34

The logic in the change() event handler is not being run when the value is set by val(), but it does run when user selects a value with their mouse

9条回答
  •  猫巷女王i
    2020-11-22 10:09

    $(":input#single").trigger('change');
    

    This worked for my script. I have 3 combos & bind with chainSelect event, I need to pass 3 values by url & default select all drop down. I used this

    $('#machineMake').val('').trigger('change');
    

    And the first event worked.

提交回复
热议问题