所以有一个h2包含以下类entry-contentH2
,而我只是想在h2之前包含以下div,但它甚至没有显示任何内容。我似乎无法弄清楚它为什么不添加它,因为当我尝试没有任何div时,我只用文本进行测试就可以了。
jQuery(function($) {
$(".entry-contentH2").before("<div class="video_player"><iframe id="ytplayer" type="text/html" width="640" height="390" src="https://www.youtube.com/embed/'.$recipe->recipe_video.'?fs=1" frameborder="0"></iframe></div>");
});
为什么.before在这种情况下不起作用的原因是什么?
答案 0 :(得分:-1)
你的iframe最有可能被youtube阻止。外部网站如:
没有加载到你的框架中,是因为他们故意利用某种Frame Killer。
建议阅读:
答案 1 :(得分:-1)
您需要将内部或外部"
更改为'
喜欢这样
jQuery(function($) { //V here V
$(".entry-contentH2").before("<div class='video_player'>hi</div>");
});
左右
jQuery(function($) { //V here and here V
$(".entry-contentH2").before('<div class="video_player">hi</div>');
})