How TO - Get Iframe Elements


Get an element from within an iframe with JavaScript.


Click the button to hide the first H1 element in the iframe (another document).


Get Element in Iframe

Get the first <h1> element inside the iframe and hide it:

Example

var iframe = document.getElementById("myFrame");
var elmnt = iframe.contentWindow.document.getElementsByTagName("H1")[0];
elmnt.style.display = "none";
Try it Yourself »

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.