js动态为video标签添加新视频
Admin | 2016-10-23 7:43:36 | 被阅次数 | 11268
一、<!-- html部分 -->
<section id="player">
<video id="media" width="100%" height="100%" controls>
<source id="v1" src="video/1.mp4">
</video>
</section>
<div class="container" width="100%" style="margin-top:20px">
<button id="u1" class="btn span2">第一章</button>
<button id="u2" class="btn span2">第二章</button>
<button id="u3" class="btn span2">第三章</button>
<button id="u4" class="btn span2">第四章</button>
</div>
二、js部分
window.onload=function(){
document.getElementById("u1").onclick=function(){
document.getElementById("v1").src="video/1.mp4";
document.getElementById("media").load();
}
document.getElementById("u2").onclick=function(){
document.getElementById("v1").src="video/2.mp4";
document.getElementById("media").load();
}
document.getElementById("u3").onclick=function(){
document.getElementById("v1").src="video/3.mp4";
document.getElementById("media").load();
}
document.getElementById("u4").onclick=function(){
document.getElementById("v1").src="video/4.mp4";
document.getElementById("media").load();
//document.getElementById("media").play();
}
}