How to Add Timestamps To Embedded YouTube Videos

April 29, 2021

In this video I will show you How to Add Timestamps To Embedded YouTube Videos.

The great thing about this code is you can use it on any type of website, so this isn’t just limited to WordPress websites. You can use this code anywhere you can enable Javascript on the page.

Elementor (Affiliate Link):
https://trk.elementor.com/4776

YouTube Javascript Code

				
					<div class="responsive-container"><div id="player"></div></div>
    <script>
      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          videoId: 'S4cZjaXmuzE',
        });
      }
      function setCurrentTime(slideNum) {
        var object = [ 0, 133, 193 ];
        player.seekTo(object[slideNum]);
      }
    </script> 
    
    

				
			

HTML Code

				
					<strong>Timestamps:</strong>
<ul>
 	<li><a href="javascript:void(0);" onclick="setCurrentTime(0)">0:00 Intro</a></li>
 	<li><a href="javascript:void(0);" onclick="setCurrentTime(1)">2:13 1 Minute Challenge</a></li>
 	<li><a href="javascript:void(0);" onclick="setCurrentTime(2)">3:13 Website Speed Results</a></li>
</ul>
<input type="button" value="1 minute challenge" onclick="setCurrentTime(2)" />
				
			

CSS Code

				
					.responsive-container {
	position: relative;
	padding-bottom: 56.25%; /* 16:9 */
	padding-top: 0px;
	height: 0;
	overflow: hidden;
}

.responsive-container iframe,
.responsive-container object,
.responsive-container embed,
.responsive-container video
{
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}
				
			

*Some of the links on this page are affiliate links, meaning we may receive a commission if you follow them. This allows us to continue providing free content and educational resources for you. Thank you for supporting our small business!

Share this post:

Facebook
Reddit
Twitter
Pinterest
LinkedIn
Email

More Free Resources

Join Our Community

Wicky Design YouTube

Get our latest videos by subscribing for FREE to our YouTube channel. New videos are uploaded weekly!