用js控制video的src_百度知道
代码如下 <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"> <bu...展开
//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();
}
}