我需要在“播放”按钮上播放视频,然后单击某个站点
我尝试使用此代码,但它不会触发YouTube视频上的播放。
jQuery(document).on('click', '.eg-henryharrison-element-2', function(event) {
event.preventDefault();
jQuery(".esg-youtubevideo").click();
});
最佳答案
您应该尝试像这样将autoplay=1
选项添加到iframe src中
<iframe width="420" height="345" src="https://www.youtube.com/embed/qYcSef6Mk58?version=3&enablejsapi=1&html5=1&controls=1&autohide=1&rel=0&showinfo=0&fs=1&playsinline=1&autoplay=1" frameborder="0" allowfullscreen></iframe>
这是在堆栈溢出时已经提出的一个相关问题:
YouTube Iframe embed auto play
关于jquery - 使用Jquery强制手动点击Youtube iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53368220/