How do you change video src using jQuery?

前端 未结 8 644
执笔经年
执笔经年 2020-12-12 14:08

How do you change the src of a HTML5 video tag using jQuery?

I got this HTML:

相关标签:
8条回答
  • 2020-12-12 14:58

    This is working on Flowplayer 6.0.2.

    <script>
        flowplayer().load({
             sources: [
                { type: "video/mp4",  src: variable }
                ]
            });
    </script>
    

    where variable is a javascript/jquery variable value, The video tag should be something this

    <div class="flowplayer">
       <video>
          <source type="video/mp4" src="" class="videomp4">
       </video>
    </div>
    

    Hope it helps anyone.

    0 讨论(0)
  • 2020-12-12 14:59

    I would rather make it like this

    <video  id="v1" width="320" height="240" controls="controls">
    
    </video>
    

    and then use

    $("#v1").html('<source src="test1.mp4" type="video/mp4"></source>' );
    
    0 讨论(0)
提交回复
热议问题