[英]How to hide div inside iframe?
I have tried the following which did not work: 我尝试了以下无效的方法:
$('iframe').contents().find('#hide_this_div').hide();
$(function() {
var $head = $('frame').contents().find("head");
$head.append("<link/>", {
rel: "stylesheet",
href: "./hide_the_div.css",
type: "text/css"
});
})
#hide_the_div {
display: none;
}
I am trying to hide the .timestamp
class in this iframe: 我试图在此iframe中隐藏
.timestamp
类:
<iframe src="https://www.facebook.com/plugins/comment_embed.php?href=https%3A%2F%2Fwww.facebook.com%2FScrapbookingCoach%2Fvideos%2F318198945603068%2F%3Fcomment_id%3D331374627618833&include_parent=false" width="560" height="141" style="border:none;overflow:hidden" scrolling="yes" frameborder="15" allowTransparency="true" allow="encrypted-media"></iframe>
Try something like this 试试这个
For example, if you want to hide h1
from <iframe>
例如,如果要从
<iframe>
隐藏h1
<iframe id="myFrame" src="#" style="height:380px;width:100%"></iframe>
function myFunction() {
var iframe = document.getElementById("myFrame");
var element = iframe.contentWindow.document.getElementsByTagName("h1")[0];
element.style.display = "none";
}
I think you need to wait for iframe is loaded. 我认为您需要等待iframe加载。
$('#my_iframe').ready(function(){
console.log('load the iframe')
var $timestamp = $('#my_iframe').find(".timestampContent");
$timestamp.hide();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.