操作指南 - 獲取 Iframe 元素
使用 JavaScript 從 iframe 中獲取元素。
點選按鈕隱藏 iframe(另一個文件)中的第一個 H1 元素。
在 Iframe 中獲取元素
獲取 iframe 中第一個 <h1> 元素並隱藏它
示例
var iframe = document.getElementById("myFrame");
var elmnt = iframe.contentWindow.document.getElementsByTagName("H1")[0];
elmnt.style.display = "none";
自己動手試一試 »