使用video.js更改<video> -tag中的src

时间:2017-09-12 21:20:06

标签: jquery html video src

我试图改变&#34; src&#34;在带有jQuery的HTML视频标签中(仅供参考:我正在使用Video.js)。

尝试使用此代码,但它无效。请帮帮我:。(

&#13;
&#13;
$(document).ready(function(){
  $(".click_me").click(function(){
    $('.video_div video source').attr('src', "small.mp4");
    $("video")[0].load();
  });
});
&#13;
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test</title>
    <script src="jquery-3.2.1.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
    <script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
    <script src="script.js"></script>
    <link href="http://vjs.zencdn.net/6.2.7/video-js.css" rel="stylesheet">
  </head>
  <body>
    <video id="my-video" class="video-js" controls preload="auto" width="640" height="264" poster="MY_VIDEO_POSTER.jpg" data-setup="{}">
      <source src="MY_VIDEO.mp4" type='video/mp4'>
      <source src="MY_VIDEO.webm" type='video/webm'>
      <p class="vjs-no-js">
        To view this video please enable JavaScript, and consider upgrading to a web browser that
        <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
      </p>
    </video>
    <script src="http://vjs.zencdn.net/6.2.7/video.js"></script>
  </body>
</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案