Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

iframe hide div

<html lang="en">
<head>
  <title>Hide element inside iframe using javascript</title>
</head>
<body>
  <p>Click on the <b>Hide Div</b> button to hide the div element inside the iframe.</p>
  <button onclick="hideDiv()">Hide Div</button>

  <iframe id="iframe-id" src="https://search.3schools.in/p/example.html" style="height:370px;width:100%">      </iframe>

<script>
function hideDiv() {
  var myIframe = document.getElementById("iframe-id");
  var divElement = myIframe.contentWindow.document.querySelector("#div");
  divElement.style.display = "none";
}
</script>
</body>
</html>
 
PREVIOUS NEXT
Tagged: #iframe #hide #div
ADD COMMENT
Topic
Name
4+7 =