JQuery code to pure JS

3

Good day yesterday I asked a question to which I responded successfully, only that when implementing it in my project, I worked with custom templates of Blogger I wanted to add the JQuery code and it does not detect the function.

$('.custom-play').click(function(){
$(this).hide();
$('#content_video').get(0).play();});

Is there any way to make that portion of code pure JavaScript?

    
asked by JesusSnd_ 24.03.2018 в 20:32
source

1 answer

3

Ideally, you would solve the problem with jQuery but if you want the alternative with Javascript pure, here you have it:

var play = document.getElementsByClassName("custom-play");
play[0].addEventListener("click", function() {
  console.log(this);
  this.style.display = 'none';
  document.getElementById("video").play();
});
.custom-play {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: url("../images/button-play.png") center center no-repeat;
}
<div id="freq-content">
  <video id="video" width="320" height="240" controls controlsList="nodownload">
    <source
      src="http://html5facil.com/demos/videos/big_buck_bunny.webm"
      type='video/webm; codecs="vp8, vorbis"'>
    <source
      src="http://html5facil.com/demos/videos/big_buck_bunny.mp4"
      type='video/mp4; codecs="avc1,mp4a"'>
    </video><br />
  <div class="custom-play"></div>
</div>
    
answered by 24.03.2018 / 21:44
source