Javascript random youtube video autoplay

后端 未结 1 988
迷失自我
迷失自我 2021-01-16 23:39

I need to display a random youtube video from a selection when the page loads. I found the question below very helpful however I can\'t figure out how to get it to autoplay.

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-16 23:53

    $(document).ready(function() {
    
    var videos = [
    'pRpvdcjkT3k',
    'Te4wx4jtiEA',
    'efTj6UYzvk4'
    ];
    
    var index=Math.floor(Math.random() * videos.length);
    var html='

    Random Video

    '; document.write(html); });

    '?' instead of '&'

    0 讨论(0)
提交回复
热议问题