【发布时间】:2012-11-20 21:23:47
【问题描述】:
我想在点击占位符(图片)时播放视频。这是代码。
html
<div class="ytembed">
<a href="http://player.vimeo.com/video/27243869?title=1&byline=1&portrait=1">
<img width="560" height="315" src="http://placehold.it/560x315" alt="Click to play"/>
</a>
</div>
jquery
$(function() {
$('.ytembed:not(.processed)').addClass('processed').each(function() {
$(this).find('a').click(function(e) {
e.preventDefault();
var width = $(this).find('img').width();
var height = $(this).find('img').height();
var url = $(this).attr('href');
var $iframe = $('<iframe src="' + url + '" width="' + width + '" height="' + height + '" frameborder="0"/>');
$(this).parent().html($iframe);
});
});
});
请告诉我该怎么做。这是jsfiddle版本http://jsfiddle.net/fEzLZ/
提前致谢。
【问题讨论】:
-
您的意思是要加载视频然后自动播放吗?因为视频加载对我来说很好。
-
是的,但我想在单击图像缩略图时播放它。谢谢...