Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a youtube embed and i wont in click to change the song
i need refresh the page?
this is the code:
html:
<iframe id='youtubePlayer' width=250 height=200 src='http://www.youtube.com/embed/faslvcx3?modestbranding=1' frameborder='0'></iframe>";


this is the juery code :
function myfunction(code_play)
{
$('youtubePlayer').attr("src","http://www.youtube.com/embed/"+ code_play + "?modestbranding=1");
}
Posted
Comments
Sergey Alexandrovich Kryukov 17-Sep-14 16:19pm    
What do you mean by "jery"? The only meaning I know is the Neomixis, a genus of bird...
—SA
jkirkerx 17-Sep-14 18:20pm    
Did you even load jquery in the head tags?

1 solution

You are using iframe..So normal selector will not work..


Try using

JavaScript
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900