我想触发$(文档)中下拉列表的更改事件.准备好使用jquery了.
I have a cascading dropdown for country and state in user details page. how can i set the value (which is taken from DB based on the user id) for country and state in MVC with C#.
我想触发$(文档)中下拉列表的更改事件.准备好使用jquery了.
I have a cascading dropdown for country and state in user details page. how can i set the value (which is taken from DB based on the user id) for country and state in MVC with C#.
I don't know that much JQuery but I've heard it allows to fire native events with this syntax.
$(document).ready(function(){
$('#countrylist').change(function(e){
// Your event handler
});
// And now fire change event when the DOM is ready
$('#countrylist').trigger('change');
});
在调用trigger()或change()之前,必须声明更改事件处理程序,否则将不会触发它.谢谢你提到@LenielMacaferi.
更多信息here.