Joomla K2项目图像悬停

时间:2015-01-30 19:06:21

标签: image video joomla hover k2

HY,

有没有办法让鼠标悬停在项目图片上,但悬停何时播放视频?

这样的东西,但不是弹出窗口: Demo

提前致谢

1 个答案:

答案 0 :(得分:0)

这不是开箱即用的。 我确定这是一个付费的扩展程序,但是如果你想用旧的方式编写代码,你可以使用jQuery和HTML5视频播放器来实现这一点。

  <video id="video" width="420">
    <source src="mov_bbb.mp4" type="video/mp4">
    <source src="mov_bbb.ogg" type="video/ogg">
    Your browser does not support HTML5 video.
  </video>

  <a id="thumbnail">Im the thumbnail</a>

<script>

jQuery(document).ready(function($) {
   jQuery('#thumbnail').hover(function() {
     jQuery('#video').show(); 
       jQuery('#video').play(); 
   }, function() {
          jQuery('#video').hide(); 
       jQuery('#video').pause(); 
   });
 }); 

</script>

我建议通过数据属性链接视频和缩略图:

例如

<a id="thumbnail" data-video="#video"></a>

<script>
jQuery(document).ready(function($) {
   jQuery('#thumbnail').hover(function() {
     jQuery(jQuery(this).data('video')).show(); 
       jQuery(jQuery(this).data('video')).play(); 
   }, function() {
          jQuery(jQuery(this).data('video')).hide(); 
       jQuery(jQuery(this).data('video')).pause(); 
   });
 }); 

</script>
缩略图上的

或使其相对于多个视频的父容器。

相关问题