通过java脚本在HTML部分添加背景视频



Hy在那里!我正试图在WordPress网站的一个部分添加背景视频。我无法编辑那个页面代码,所以我必须通过JavaScript添加它。这是网站页面链接:http://listchicagocondo.com/index.php/new-form/.在第一节背景中,我想添加视频。

我尝试添加jQuery属性,但没有成功。

试试这个,你可以根据你的要求添加更多的属性

<script>
window.addEventListener('load', (event) => {
// Create the text node for video element.
var video = document.createElement('video');  
// Create the text node for source element.
var source = document.createElement('video');  
//add id attribute on video tag    
video.setAttribute('id', 'video');
source.src='video.mp4';
video.appendChild(source);

});
</script>

最新更新