video tag controlling by javascript

3

How do I, when I click on the video, it starts loading, because I can not if someone can help thanks.

Here is the video snippet:

<div class="video">
   <video class="video" loop controls tabindex="0">
      <source src="video/nome_do_video.mp4"/>
   </video>
</div>
    
asked by anonymous 24.08.2015 / 20:57

1 answer

3

The name of the method is play (), however, it should be accessed by the DOM tree because it is not a JQuery method, but rather a DOM Object.

jQuery( document ).ready(function($) {
    $('video.video').click(function() {
        $(this).get(0).paused ? $(this).get(0).play() : $(this).get(0).pause();
    });
});

In this script, if the video is paused, the action of play() will be triggered, otherwise it will be paused.

    
24.08.2015 / 21:07