[英]Child Requesting OnChange request of Parent Window element
So I have this in my child iframe has this code running with in it. 因此,我的孩子在iframe中拥有此代码,并在其中运行了此代码。
window.parent.document.getElementById("cs_0000").onchange = function () {
alert('Worked');
};
For what ever reason it's not working. 无论出于什么原因,它都不起作用。
I can run this code: 我可以运行以下代码:
window.parent.document.getElementById("cs_0000").value;
and it will return the value of that element but the on change event doesn't work. 并且它将返回该元素的值,但是on change事件不起作用。
The result was because the hidden fields don't trigger change events. 结果是因为隐藏字段不会触发更改事件。
So after using: 因此,使用后:
.trigger("change");
I was able to catch the event using: 我能够使用以下方法捕获事件:
window.parent.jQuery('#something').on('change', function(){
// Put stuff here
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.