可以使用 jQuery 的 'trigger()' 方法来触发 select 的 change 事件。假设 select 的 id 为 'select1',则代码如下:

$('#select1').trigger('change');

如果要在 iframe 中执行这个代码,则需要先获取 iframe 对象,然后再在该对象上执行相应的代码。假设 iframe 的 id 为 'myFrame',则代码如下:

var iframe = document.getElementById('myFrame');
var iframeDoc = iframe.contentWindow.document;
$(iframeDoc).find('#select1').trigger('change');
如何触发 iframe 中 select 的 change 事件

原文地址: https://www.cveoy.top/t/topic/nEnp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录