Return to Snippet

Revision: 61778
at January 15, 2013 01:59 by vijayrajesh

Initial Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" lang="en-US">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Dynamically Load Youtube Video Iframe embed code inside a DIV</title>
<link href=',300,600,700' rel='stylesheet' type='text/css'><script  type="text/javascript" src=""></script>
		margin	: 0;
		padding	: 0;
		background	: #EEE;
		color		: #333;
		font-family: 'Open Sans', sans-serif;
		font-size	: 12px;
		width	: 1012px;
		margin	: 0 auto;
		width	: 560px;
		height	: 315px;
		border	: 1px solid #333;
		width	: 301px;
		height	: 85px;
		border: 1px solid #AAA;
		padding: 3px 5px;
		text-decoration: none;
		background: #333;
		color: #FFF;
	<div id="wrapper">
		<h1>Dynamically Load Youtube Video Iframe embed code inside a DIV</h1>
		<textarea class="embed-code"><iframe width="560" height="315" src="" frameborder="0" allowfullscreen></iframe></textarea> 
		<p>You can also paste any Iframe Youtube Video Code above.</p>
		<p><a href="#" class="btn-load-video">Load the video</a></p>
		<div class="the-player">
		<p>Demo by : <a href="">WordPress Themes</a> </br>
		Article Link : <a href="">Article on Dynamically Load Youtube Video Iframe embed code inside a DIV</a>
	<script type="text/javascript">
	$(document).ready(function() {
		$('.btn-load-video').click(function() {

Initial URL

Initial Description
By storing or by having the Iframe embed code as a variable, You can play the Youtube video on a click of a button or any other event.  I have used “append” function of jQuery to append the IFrame code dynamically inside a DIV tag.

Initial Title
Dynamically Load Youtube Video Iframe embed Code inside a DIV

Initial Tags

Initial Language