2015-02-24 56 views
-4

HTML ID輸出試圖讓視頻源src和海報HTML ID輸出如何獲得在SRC

<video id="really-cool-video" class="video-js vjs-default-skin" controls 
preload="auto" width="640" height="264" poster="$('#posterURL').html();" 
data-setup='{}'> 
    <source src="$('#videoURL').html();" type='video/mp4'> 
</video> 

<div id="posterURL"></div> 

<div id="videoURL"></div> 
+0

HTTP ://stackoverflow.com/help/how-to-ask – knitevision 2015-02-24 12:37:34

回答

0

您可以使用jQuery的.attr() -function此:

$(document).ready(function(){ 
    var posterUrl = $('#posterURL').html(); 
    var videoUrl = $('#videoURL').html(); 

    $('#really-cool-video').attr('poster', posterUrl); 
    $('source').attr('src', videoUrl); 
)};