Answer the question
In order to leave comments, you need to log in
Clicking on the rest of the video, closes the open one?
There is a video list
<ul class="video__list">
<li class="video__item">
<video src="video-1.mp4" class="video__vid" controls></video>
</li>
<li class="video__item">
<video src="video-2.mp4" class="video__vid" controls></video>
</li>
<li class="video__item">
<video src="video-3.mp4" class="video__vid" controls></video>
</li>
</ul>
$(document).ready(function(){
$('.video__vid').click(function(){
var $this = $(this),
item = $this.closest('.video__item'),
list = $this.closest('.video__list'),
otherItems = list.find('.video__item'),
otherVideos = list.find('.video__vid');
console.log(item);
console.log(list);
console.log(otherItems);
console.log(otherVideos);
// $this.get().pause();
$this.get(0).play();
});
});
Answer the question
In order to leave comments, you need to log in
$('.video__vid').click(function(){
//Остановим старое
var old = $(".active").removeClass("active").get(0);
old && old.pause();
//Запустим новое
$(this).addClass("active");
this.play();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question