G
G
grishaaa2017-05-15 08:46:23
css
grishaaa, 2017-05-15 08:46:23

How to play video on button click? But how to solve one small problem?

Guys!!! I beg you, help!!
There are a lot of videos on the site, and how can I run each one separately, with minimal js code.
I don't want to write my own code for each video.
In each block with a video there will be a button, when clicked, the video should start.
How to do it!!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2017-05-15
@nikopol484

If you use jquery then:

$('.button_class').click(function(){
   var video_params = $(this).parent().data('video');
  // тут запуск проигрывателя и прочее
})

html should look something like this:
<div class="video_block" data-video="параметры видео для запуска">
  <div class="button_class"></div>
</div>
<div class="video_block" data-video="параметры видео для запуска">
  <div class="button_class"></div>
</div>

and so on, the main thing is that all video blocks have the same structure

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question