Trying to load a video dynamincally from a gallery
this code is suppose to do, is when the user clicks the image in the #thummbnails_div, the Text in #show_div is replaced with the youtube video with that ID . Since i am new here i can't post images. So the code to insert an image is incorrect i know. Thanks in advance.
<script type="text/javascript"> $(document).ready(function(){$("#thumbnails_div img").click(function(){ var youtubeID=$(this).attr("id"); $("#show_div").empty(); $("#show_div").append("<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/+youtubeID+rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.come/v/"+youtubeID+"$rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>"); })开发者_JS百科; }); </script> <divid="show_div">Click pic below to see video</ div> <div id="thumbnails_div"><image id="OrgSdZH_rkU" src="http://img.youtube.com/vi/OrgSdZH_rkU/default.jpg" /></div>
Your quotes are so wrong in the jQuery append method, it looks like this when you try to beautify the code
$(document).ready(function () {
$("#thumbnails_div img").click(function () {
var youtubeID = $(this).attr("id");
$("#show_div").empty();
$("#show_div").append("<object width="
425 " height="
355 "><param name="
movie " value="
http: //www.youtube.com/v/+youtubeID+rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.come/v/"+youtubeID+"$rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>"); }); });
You need to escape your double quotes with \ or you should use a single quote to surround the string. JavaScript 101.
精彩评论