[英]Get event of dropdown change value in jQuery
I want to get the event whenever my dropdown change its value 每当我的下拉菜单更改其值时,我都希望获得该事件
currently i'm using: 目前我正在使用:
$('#dropdown').on('change', function() {
// doing some process here
}
but what I want is to get the event even when changing the value of the dropdown through jQuery. 但是我想要的是获取事件,即使通过jQuery更改下拉列表的值也是如此。 Lets say I do something like this:
可以说我做这样的事情:
$('#dropdown').val( someValue );
I also want to catch the code above on the change event. 我也想在change事件中捕获上面的代码。
Is there a way for jQuery to get this event? jQuery是否有办法获取此事件?
if you change the value via jQuery, you can trigger the change event on that element with: 如果您通过jQuery更改值,则可以使用以下命令触发该元素的change事件:
$('#dropdown').val( someValue ).change();
or 要么
$('#dropdown').val( someValue ).trigger('change');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.