开发者

Switching from a JPG with a YouTube video

开发者 https://www.devze.com 2023-03-21 20:39 出处:网络
I have a 940x520px JPG on my webpage inside of a DIV and I would like to make it a link so when you click on it a YouTube video of 940x520px replaces the JPG and automatically starts playing.

I have a 940x520px JPG on my webpage inside of a DIV and I would like to make it a link so when you click on it a YouTube video of 940x520px replaces the JPG and automatically starts playing.

What would be the best way of using Javascript to make this wo开发者_C百科rk?

Thanks


Use an onClick (or click if you are using jQuery) to repalce the image with the code for the embedded youtube player.


<div class="image">
    <img class="img" />
</div>
<div class="youtube" style="display:none;">
    <!--Youtube code here-->
</div>

<script>
    $(document).ready(function () {
        $(".img").click(function () {
            $(".image").hide();
            $(".youtube").show();
        });
    });
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消