Line 1: |
Line 1: |
− | <html>
| |
− | <head>
| |
− | <title>YouTube Video Click Play</title>
| |
− | <style>
| |
− | .video-container {
| |
− | display: flex;
| |
− | flex-wrap: wrap;
| |
− | justify-content: center;
| |
− | gap: 20px;
| |
− | }
| |
| | | |
− | .video-box {
| |
− | position: relative;
| |
− | width: 400px;
| |
− | height: 240px;
| |
− | }
| |
− |
| |
− | .play-button {
| |
− | position: absolute;
| |
− | top: 50%;
| |
− | left: 50%;
| |
− | transform: translate(-50%, -50%);
| |
− | font-size: 40px;
| |
− | color: white;
| |
− | cursor: pointer;
| |
− | }
| |
− |
| |
− | .video-iframe {
| |
− | width: 100%;
| |
− | height: 100%;
| |
− | }
| |
− | </style>
| |
− | </head>
| |
− | <body>
| |
− | <div class="video-container">
| |
− | <div class="video-box">
| |
− | <div class="play-button" onclick="playVideo('efR1C6CvhmE')">▶</div>
| |
− | <iframe class="video-iframe" src="https://www.youtube.com/embed/efR1C6CvhmE"></iframe>
| |
− | </div>
| |
− |
| |
− | <div class="video-box">
| |
− | <div class="play-button" onclick="playVideo('VIDEO_ID_2')">▶</div>
| |
− | <iframe class="video-iframe" src="https://www.youtube.com/embed/VIDEO_ID_2"></iframe>
| |
− | </div>
| |
− |
| |
− | <!-- Add more video boxes as needed -->
| |
− | </div>
| |
− |
| |
− | <script>
| |
− | function playVideo(videoId) {
| |
− | var iframe = document.createElement('iframe');
| |
− | iframe.src = 'https://www.youtube.com/embed/' + videoId + '?autoplay=1';
| |
− | iframe.width = 400;
| |
− | iframe.height = 240;
| |
− | iframe.setAttribute('allow', 'autoplay');
| |
− |
| |
− | var videoBox = event.target.parentNode;
| |
− | videoBox.innerHTML = '';
| |
− | videoBox.appendChild(iframe);
| |
− | }
| |
− | </script>
| |
− | </body>
| |
− | </html>
| |