title: How to play pause video on scroll
body: <p>I want to play or pause video on scroll, if scroll is greater than <strong>300</strong> it should pause otherwise it should play. This is my video tag </p>
  
  <pre><code>&lt;video width="100%" controls &gt;
     &lt;source src="video.mp4" type="video/mp4"  &gt;
   &lt;/video&gt;
  </code></pre>
  
  <p>And the Jquery </p>
  
  <pre><code>$(document).ready(function(){
      var scroll = $(window).scrollTop();
      if(scroll &gt; 300){ 
          $('video').attr('autoplay':'false')
      }
      else{
          $('video').attr('autoplay':'true')
      }
  })
  </code></pre>
  
  <p>Now I'm not using autoplay attr directly. Please help me how can I fix  this ? </p>
  
  <p><strong>Edit :</strong></p>
  
  <pre><code>i updated my code to this 
  $(document).ready(function(){
              $(window).scroll(function(){
                  var scroll = $(window).scrollTop();
                      if(scroll &gt; 300){ 
                      $('#videoId').get(0).pause()    ; 
                      }
                  else{
                      $('#videoId').get(0).play();
  
                  }   
              })
          })
  </code></pre>
  
  <p>still does not work </p>