JSFiddle - React, Tailwind, and code Playground

by pleinx

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Event Bubbling</title>
</head>
<body>
  <div id="parent">
   <iframe id="child" width="560" height="315" src="https://www.youtube.com/embed/icgGyR3iusU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  </div>
  
  <script>
    var parent = document.querySelector('#parent');
    <!-- Add click event on parent div -->
      parent.addEventListener('click', function(){
        console.log("Parent clicked");
        child.dispatchEvent(document.createEvent("click"));
      });
  </script>
</body>
</html>

CSS

#parent {
  height: 800px;
}