Speed up development with full-stack environments for every branch.

Learn More

jQuery Youtube Videos iframe popup [JavaScript]

Forked from How to use the jQuery $().ready function.

6998 Runs 13352 Views 8519 Copies

YouTube iframe video in light box on click of the image.

Saved

Saved

sruniti 8

sruniti
published 3 years ago

$(function(){
  $('.youTubeVideo').click(function(){
 		var vidtitle = $(this).parents('.videoThum').next('.videoInfo').find('h2').text();
		$('.video-container .iframe h2').text(vidtitle);
		var winWidth = $(window).width();
        var winHeight = $(window).height();
        var centerDiv = $('.popup');
        var left = winWidth / 2 - ((parseInt(centerDiv.css("width"))) / 2);
        var top = winHeight / 2 - ((parseInt(centerDiv.css("height"))) / 2);
        centerDiv.css({'left': left,'top': '15%'});
    		$('.youtube').show();
		  $('.popup.youtube, .overlaybg').show();
		 $("html,body").animate({scrollTop: 0}, 800);
 		var ind = $(this).parents('.videoThum').addClass('aaa').parents('.guideBox').siblings().find('.videoThum').removeClass('aaa');	
		var linkSrc = $(this).parents('.videoThum').find('a').attr('rel');
		 $('.youtube .video-container').find('iframe').attr('src', linkSrc);
	});	
	
	$('.close, .overlaybg').click(function(){
		$('.youtube .video-container').find('iframe').attr('src', '');							
		$('.popup.youtube, .overlaybg').hide();
	});	
	});	
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).