0
通過單擊位於父級的輸入字段中的iframe(相同域)內的按鈕來添加值。當jquery更新輸入值時如何更改輸入值
我需要之後通過靶向在輸入域的變化,但因爲它發生的jQuery,而不是手動+因爲它是從IFRAME父做我不能檢測到它...
這裏是小提琴,但我不能真的模擬它在提琴iframe是參與...
`
<iframe id="someiframe">
<div id="container">
<div id="thebutton" class="btn">
<button>add value to input field</button>
</div>
</div>
</iframe>
<input class="someclasss" type="text" name="somename" id="target" maxlength="8" value="">
<div id="check">if detected i will become yellow</div>
// passing the value by click
jQuery("#thebutton").click(function() {
jQuery("#target").val("12345678");
jQuery("#target").trigger('change');
});
// detecting value passing
jQuery("#target").on('change input paste', function() {
jQuery("#check").css("background", "yellow");
alert("OK - DETECTED CHANGE");
});
#check {
display: block;
height: 30px;
width: auto;
border: 1px solid black;
}
` https://jsfiddle.net/ogasbo73/