【发布时间】:2019-05-18 19:34:46
【问题描述】:
我有一个带有 onchange 属性的选择框 我可以更改框的值,但不能自动触发 onchange
<select name="name" id="id7c7" onchange="if (function()....">
$(document).ready(function() {
var id1 = $( "select:first-of-type" ).attr('id')
var event = new Event('onchange', { 'bubbles': true });
console.dir();
// sets first drop to category
$( "select:first-of-type" ).val( "2" );
$( "select:first-of-type" ).dispatchEvent(event)'
});
【问题讨论】:
标签: jquery html events select listener