zoukankan      html  css  js  c++  java
  • javascript创建节点的事件绑定

    javascript创建节点的事件绑定

    timeupdate事件是<video>中用来返回视频播放进度的事件,绑定在<video>标签返回视频播放位置(每秒计)。

    现video标签需要直接在js中创建出来,

     video = document.createElement( 'video' );

    无法直接绑定timeupdate事件。

    解决方法:

    1.直接调用  ontimeupdate

    video = document.createElement( 'video' );
    video.ontimeupdate= function() { //实时更新播放进度条和时间
                        var currentPos = video.currentTime; //Get currenttime    //当前时间
                        var maxduration = video.duration; //Get video duration   //总时间
                }

    2.<video>标签和video对象互转

    video = document.createElement( 'video' );
    var videos = $(video);
     video.on("timeupdate", function() {           //实时更新播放进度条和时间
                        var currentPos = video[0].currentTime; //Get currenttime    //当前时间
                        var maxduration = video[0].duration; //Get video duration   //总时间
                }

    附:<video>标签和video对象的区别

    将html中的<video>标签在控制台打印后结果为:

    用javascript中   video = document.createElement( 'video' );    创建一个video对象打印出来为:

    video对象就等于<video>标签对象中的video[0]。

  • 相关阅读:
    用JSP实现的商城购物车模块
    C语言中的static 具体分析
    JAVA动态代理
    ACM之跳骚---ShinePans
    thinkphp5项目--个人博客(二)
    mysql数据类型
    htm、html、shtml网页区别
    thinkphp命名空间
    github README.md教程
    如何在github的README.md中添加图片
  • 原文地址:https://www.cnblogs.com/s313139232/p/8358365.html
Copyright © 2011-2022 走看看