Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hack-way/youtube-thumbnail-pop-up-video

This code creates @Hackway A modal window that displays a YouTube video when a thumbnail is clicked. The modal window has a close button that closes the window when clicked.
https://github.com/hack-way/youtube-thumbnail-pop-up-video

modal modal-window pop-up popup thumbnail youtube youtube-video

Last synced: about 1 month ago
JSON representation

This code creates @Hackway A modal window that displays a YouTube video when a thumbnail is clicked. The modal window has a close button that closes the window when clicked.

Awesome Lists containing this project

README

        

# YouTube Thumbnail pop up video

This code creates a modal window that displays a YouTube video when a thumbnail is clicked. The modal window has a close button that closes the window when clicked.

## Here is a more detailed explanation of the code:

1) The thumbnails variable is an array of all the thumbnail elements on the page.
2) The modalContainer variable is a reference to the modal-container element on the page.
3) The videoIframe variable is a reference to the video-iframe element on the page.
4) The closeButton variable is a reference to the close-button element on the page.
5) The thumbnails.forEach() loop iterates through the thumbnails array and adds an event listener to each thumbnail element.
6) The event listener for each thumbnail element is a function that gets the video ID from the dataset.id property of the thumbnail element and then sets the src property of the videoIframe element to the YouTube embed URL for the video ID.
7) The videoIframe element then displays the YouTube video.
8) The closeButton event listener sets the src property of the videoIframe element to an empty string and then sets the display property of the modalContainer element to none.

### Live Domo || YouTube Thumbnail pop up video:
The link https://codepen.io/hackway/pen/eYLbeVW

YouTube channel my Handle is @Hackway I hope this helps! Let me know if you have any other questions.