I want to create a div inside an iframe, call the divID and change it. Can it be done from the head using JS?
Here is what I tried and won't work for me:
console.log(document.getElementById("mydiv").id);
document.getElementById("myDiv").setAttribute("id", "MyDiv2");
console.log(document.getElementById("MyDiv2").id);
<body>
<div id="mydiv" style="border: solid 2px #000;">
<iframe height="100px" width="100%" name="iframe_a"></iframe>
<div>
<h2>This is mydiv</h2>
</div>
</div>
</body>