play youtube video on click custom button
===

I do have following code where i want to play youtube video when button is clicked.

I have iframe code for youtube.


	<script>
				
				var player = document.getElementById("myplayer");

				//Create a simple function and check if player exists
				function play() {
				    if(player) {
				        player.playVideo();
				    }
				}

			
     </script>


	<iframe id="myplayer" width="500" height="500" src="http://www.youtube-nocookie.com/embed/C-VoyCDUvr0?rel=0&wmode=Opaque&enablejsapi=1" frameborder="0" allowfullscreen></iframe>

	<a href="#" onclick="play()">Play Youtube Video</a>


But it does not play when i click on button / link

I put script code in head part of html and iframe and anchor link in body part of html.

Am i missing anything?