<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.video-warp {
max-width: 40rem;
margin: 0 auto;
}
.video-play {
position: absolute;
top: 50%;
left: 48%;
background: url(icon-bofang.png) no-repeat;
background-size: 100% auto;
border-radius: 0.2rem;
width: 7rem;
height: 7rem;
z-index: 15;
margin: -0.65rem 0 0 -0.65rem;
}
</style>
</head>
<body>
<div class="container">
<div class="video-warp wow fadeInUp">
<video id="myVideo" title="" controls src="https://cdn.multi-masters.com/ys/72a99f7b-3299-418c-b49c-81927b134eee-ys.mp4" style="width: 100%; object-fit: fill" poster=""></video>
<a href="javascript:;" onclick="toggleSound()" class="video-play"><i class="icon-play"></i></a>
</div>
</div>
</body>
<script SRC="../js/jquery.min.js"></script>
<script>
function toggleSound() {
var video = document.getElementById('myVideo');
if (video.paused) { //如果已暂停则播放
$('.video-play').hide();
video.play(); //播放控制
} else { // 已播放点击则暂停
$('.video-play').show();
video.pause(); //暂停控制
}
}
</script>
</html>
jQuery点击控制视频播放
最新推荐文章于 2024-01-18 17:03:37 发布