0

So there is a h2 that contains the following class entry-contentH2 and I'm simply trying to include the following divs before that h2 but it's not even showing anything. I can't seem to figure out why it isn't adding it, because when I try it without any divs and I test with just text it works.

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>");
});

What is the reason as to why .before doesn't work in this case?

Here is the code: https://jsfiddle.net/or9Lbbq0/2/

iBrazilian2
  • 2,204
  • 6
  • 23
  • 45

2 Answers2

-1

Your iframe is most likely being blocked by youtube. External websites such as:

  • youtube.com
  • google.com
  • stackoverflow.com
  • etc.

are not loading in your frame, is because they are intentionally leveraging some sort of Frame Killer.

Suggested reading:

see simular problem here

Community
  • 1
  • 1
Arthur Putnam
  • 1,026
  • 1
  • 9
  • 26
  • Thanks but that I already knew it isn't the problem. It's just not moving divs, iframes, but if I include just text without any div it includes it before the h2. But thanks for your response. – iBrazilian2 Jul 08 '16 at 20:45
-1

you need to change the inner or outer " to '

like so

jQuery(function($) {                       //V here       V
    $(".entry-contentH2").before("<div class='video_player'>hi</div>");
});

or so

jQuery(function($) {           //V here                    and here V 
    $(".entry-contentH2").before('<div class="video_player">hi</div>');
})

jsfiddle

grabthefish
  • 962
  • 14
  • 30