jquery replace youtube embed
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Hi there,

I want a jquery script that when a user clicks the play button on my embedded youtube videos, instead of it opening and playing the video I want it to open the youtube page in a new tab.

Thanks

  • Dave
5 months ago
Tags
jQuery

Crowdsource coding tasks.

4 Solutions

Hi that is great but I can't add a div around the youtube video. Unless it is done with jquery. And it also what if the video isn't width="560" height="315"
davesargent 5 months ago
Hi Dave frame width and height can be anything also the div i will try to add via jquery
Subhash Dasyam 5 months ago
do you mind sharing your html so that i can tweak and send you asap
Subhash Dasyam 5 months ago

Hi Dave,

Take a look at my solution here-

Demo: http://codepen.io/hue94/full/XMGmbe/

Source: http://codepen.io/hue94/pen/XMGmbe

Just enter the video url in the javascript file to make it work.

:-)


well here is my working solution, it's really simple, even to integrate it in your code. no need to jquery at all, made in simple HTML!

All you have to do, is to insert the videoID in the img and a elements.

<div class="videos">
    <a href="https://www.youtube.com/watch?v=F5FEj9U-CJM" target="_blank" class="video">
        <span></span>
        <img src="https://i1.ytimg.com/vi/F5FEj9U-CJM/maxresdefault.jpg" alt="True Facts About The Mantis Shrimp" />
    </a>
</div>

link: https://jsfiddle.net/yjj8s42g/

View Timeline