Dynamically Load Youtube Video Iframe embed Code inside a DIV
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.
How it Works :
The textarea contains the iframe code. Please note that you can embed any Youtube Iframe embed code and click on the button. The button is just a link. It uses “event.preventDefault(); ” function to avoid page refresh.
I have tested it in IE, Firefox. Please check in your browsers too. Please comment and enhance the code.
Disclosure: Some of the links in this post are "affiliate links." This means if you click on the link and purchase the item, I will receive an affiliate commission.