title: Video stop on div hide
body: <p>I know this has been addressed before but I don't know enough about code to apply the other solutions to my own problem, since my code is different. My video is not a Youtube video, its just in my web folders.</p>
  
  <p>Basically I have the video popping up in a div on autoplay. When you click of the vid hides, which I want, but the audio keeps playing. I just want the video to stop playing when the div is hidden, and I can't seem to figure out how to plug in the correct code. If someone could help me I'd really appreciate it. Thanks.
  This is my script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  document.onclick=check; 
  function check(e){ 
  var target = (e &amp;&amp; e.target) || (event &amp;&amp; event.srcElement); 
  var obj = document.getElementById('mydiv'); 
  if(target!=obj){obj.style.display='none'} 
  } 
  &lt;/script&gt;
  
  
   &lt;div id="mydiv"&gt;&lt;video autoplay&gt;&lt;source src="socialphobiavideo.mp4"&gt;&lt;/video&gt;&lt;/div&gt; 
  </code></pre>