简体   繁体   English

检测动态表单输入更改

[英]Detect dynamic form input change

I'm attempting to perform an action when my form's inputs are changed, but it is not working. 当表单的输入更改时,我试图执行一个操作,但是它不起作用。 My form is added dynamically: 我的表格是动态添加的:

<iframe onload="javascript:parent.scrollTo(0,0);" 
  height="447" allowTransparency="true" frameborder="0" scrolling="no" 
  style="width:100%;border:none" src="https://emu.edu/machform/embed.php?id=38142"
  title="Form"><a href="https://emu.edu/machform/view.php?id=38142" title="Form">Form</a>
</iframe>

Here's my jQuery: 这是我的jQuery:

function doThis() {
    alert("Form changed!");
}

$("iframe").on('change', 'input', doThis);

You have to wait for the iframe to load: 您必须等待iframe加载:

$('iframe').load(function() {
  $("iframe").contents().find("input").on("change", doThis);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM