jquery - Play youtube video when clicking on a preview image, php and javascript -


i using javascript make preview image play youtube video on click event:

$(document).ready(function(){      $("#feature_content").click(function(){         var iframe = "<iframe />";          var url = "http://www.youtube.com/embed/serial_number?autoplay=1&autohide=1&modestbranding=1&rel=0&hd=1";          var width = 600;         var height = 335;         var frameborder = 0;           $(iframe, {             name: 'videoframe',             id: 'videoframe',             src: url,             width: '600',             height: '335',             frameborder: 0,             class: 'youtube-player',             type: 'text/html',             allowfullscreen: true         }).css({'position': 'absolute', 'top': '11px', 'left': '11px'}).appendto(this);          $(this).find('img').fadeout(function() { $(this).remove();});       });      }); 

this code works well, problem need switch url dynamically...and variable php.

<?php   $url = get_post_meta($id, $youtube[$number], true); // wordpress function   ?> 

how pass url php javascript? jquery ajax call?

you have php output valid javascript, like

var url = "<?php echo get_post_meta($id, $youtube[$number], true); ?>"; 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -