html5中fullpage怎么用,javascript – HTML5视频自动播放功能无法在fullpage.js中运行

这篇博客介绍了如何利用fullpage.js的afterRender回调在页面结构生成后初始化其他插件或执行依赖DOM就绪的代码。通过示例代码展示了在页面部分加载时自动播放视频的方法,并提供了更新信息,指出从fullpage.js 2.6.6版开始,只需在视频标签中添加data-autoplay属性即可实现自动播放。
摘要由CSDN通过智能技术生成

你应该使用fullpage.js插件提供的

afterRender回调.

afterRender()

This callback is fired just after the structure of the page is generated. This is the callback you want to use to initialize other plugins or fire any code which requires the document to be ready (as this plugin modifies the DOM to create the resulting structure).

您可以查看实时示例here,或者甚至可以在fullpage.js下载的the examples folder中找到它.

您可以轻松查看其使用的源代码:

$(document).ready(function () {

$('#fullpage').fullpage({

verticalCentered: true,sectionsColor: ['#1bbc9b','#4BBFC3','#7BAABE'],afterRender: function () {

//playing the video

$('video').get(0).play();

}

});

});

UPDATE

在fullpage.js>中不再需要这样做. 2.6.6.

只要在其中包含标签自动播放,它将在访问该部分时自动播放视频:

如果您只想在部分加载(而不是页面加载)上播放它,请使用data-autoplay.

更多信息at the documentation.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值