You are using iframe..So normal selector will not work..
Try using
function myfunction(code_play)
{
$("body").find('#youtubePlayer').attr("src","http://www.youtube.com/embed/"+ code_play + "?modestbranding=1");
}
And also in your code the selector used in wrong way
$('youtubePlayer') :- This is wrong
$('#youtubePlayer') :- This is correct