救命!有人可以告诉我我在做什么错吗?我正在尝试产生一个可点击的图片链接,以便在点击该链接时会启动我的youtube视频。这就是我所拥有的...
<iframe class="youtube" width="400" height="257" src="http://www.youtube.com/embed/I-TiwjSELQE?autoplay=1" frameborder="0" allowfullscreen imgsrc="images/ciafree-yt" width="413" height="242"></iframe>
谢谢 : )
最佳答案
您可以使用jQuery,只需将id="yt-video"
添加到您的嵌入代码中。
确保在HTML中也引用jQuery(https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js
)。
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" ></script>
然后添加这个简单的jQuery:
<script>
$(document).ready(function() {
$('#yt-video').hide(); // hides the video initially
$('#id_of_image_div_clicked').click(function(){
$('#id_of_image_div_clicked').hide(); // hides the clicked image
$('#yt-video').show(); // shows the video
}
});
</script>
关于youtube - 帮助YouTube嵌入!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5873678/