[js]js中把时间currentTime值转为分钟与数数
JS 如何把 duration 秒 转为 时分秒显示 currentTime,[js]js中把时间currentTime值转为分钟与数数
- function timeUpdate() {
- document.getElementById('time').innerHTML = video1.currentTime;
- }
- function durationChange() {
- document.getElementById('duration').innerHTML = video1.duration;
- }
- window.onload = function () {
- var videoPlayer = document.getElementById("video1");
- videoPlayer.ontimeupdate = function() { timeUpdate(); };
- }
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 +
'秒'
;
热门文章推荐
- [JS]window.location获取url各项参数详解
- [JS]jQuery,javascript获得网页的高度和宽度
- [JS]视频弹窗视频弹出层videoLightBox(含三种播放器的用法)
- [JS]JS提交中文encodeURI两次转码
- [JS]js版方面encodeURI转码和decodeURI解码的用法实例
- [JS]js取当前机子的时间戳实例
- [JS]AES加密(基于crypto-js)PHP后端解密
- [JS]data:image/png;base64写法的用途及说明
请稍候...