我试图运行连续循环的视频幻灯片。我已经设置了基于div id的数组,但是我收到一条错误消息,指出索引未定义。下面是HTML:当我尝试循环播放视频数组时,未定义视频阵列
<div id="div1" class="video"><video class="vidarray" src="icx.mp4"></video></div>
<div id="div2" class="video"><video class="vidarray" src="icx2.mp4"></video></div>
<div id="div3" class="video"><video class="vidarray" src="lastvid.mp4"></video></div>
CSS:
div {
height: 1080px;
width: 1920px;
display: none;
}
的jQuery:
var videos = [
'div1',
'div2',
'div3',
]
var videos = [
['div1' , 2000],
['div2' , 2000],
['div3' , 2000],
]
// Initate a counter at 1 because you're going to show the first video by default.
var counter = 1;
setInterval(function(){
// Hide all the video divs
$(".video").hide();
// Show the video div based on the counter
$('#'+ videos[counter][0]).show();
// Reset the video to the beginning
$('video' +[counter]).load();
// Play the video
$('video' + [counter]).play();
//Increment the counter if there are still more divs to show, otherwise reset it to 0
counter == videos.length-1 ? counter = 0 : counter++;}, videos[counter][1]);
负载(),这是jQuery的文档中的问题......指数为空.. 。
jQuery.fn.load = function(url, params, callback) {
var selector, type, response,
self = this,
off = url.indexOf(" ");
哪个索引没有定义? – Taysumi
第27行... $('#'+“video”+ [counter])。load(); – KevMoe