fancybox youtube showing video links in a lightbox

do people still use lightboxes, it seems yes in some cases. ;)

if you feel the urge to use lightboxes and need to link to some youtube videos this is how you can do it.

you will need jquery and fancybox and a youtube video link for this to work

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.1.20/jquery.fancybox.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.1.20/jquery.fancybox.js"></script>

I found this example somewhere, cant remember where that adds the fancybox code to any link with the class video

<script>jQuery(document).ready(function() {

	$(".youtube").fancybox({
	    type: "iframe"
	});

});</script>

Add a link to the video, e.g:

here is a test link

Click it to see if it works...

View Demo

Demo

Other Items in js
Page Views

This page has been viewed 140 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹