Try adding element to the iframe document body:
function Addcompntn() {
var framedeki = document.getElementById('if1').contentWindow.document;
var div = document.createElement("div");
div.id = 'innerdiv';
div.style.color = 'white';
framedeki.getElementById('example').append(div);
}
I want to add input in a div content javascript but it doesn’t add
HTML:
<button onclick="Addcompntn();" class="btn btn-success">Add</button>
<iframe class="embed-responsive-item" src="index.html" allowfullscreen id="if1"></iframe>
Script:
function Addcompntn() {
var framedeki = document.getElementById('if1').contentWindow.document;
$('example').append('<div id="innerdiv" style="color:white;"></div>');
}
index.html
<div id="example" style="z-index:2"> //dynamic data will come here </div>
If it’s not on the same domain .. And you don’t have access to the
Thanks, it worked successfully and I can configure the div, but how can I add div inside div, not body
@Muhammed just get element that you need inside iframe and append that div to it. I’ve updated my answer.