javascriptjqueryhtml5-videonativeposter

How change the video tag poster attribute with javascript?


I want to use either native JavaScript or jQuery to change the poster attribute on the HTML video tag. Any help would be greatly appreciated.

<div id="videoplayer" class="video-player" style="overflow: hidden; width: 582px; height: 326px; "> 
    <div id="myPlayer"> 
        <video id="htmlFive" width="100%" height="100%" controls="" poster="undefined">
            <source src="blank.m3u8">
        </video>
</div> 
     </div>

Thank you!


Solution

  • To do it natively, just change the attribute:

    document.getElementById('htmlFive').setAttribute('poster','newvalue');