宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应

[js]js中把时间currentTime值转为分钟与数数

2016-10-13 00:16:48 点击量:66 标签: 收藏本文

  1. function timeUpdate() { 
  2.             document.getElementById('time').innerHTML = video1.currentTime; 
  3.         } 
  4.  
  5.         function durationChange() { 
  6.             document.getElementById('duration').innerHTML = video1.duration; 
  7.    
  8.         } 
  9.         window.onload = function () { 
  10.             var videoPlayer = document.getElementById("video1"); 
  11.             videoPlayer.ontimeupdate = function() { timeUpdate(); }; 
  12.         } 
  13.   
var hour = Math.floor (video1.duration / 3600);
var other = video1.duration % 3600;
var minute = Math.floor (other / 60);
var second = (other % 60).toFixed (2);
document.getElementById ('duration').innerHTML = hour + '时' + minute + '分' + second + '秒';