在输入标签内显示持续时间而不是预标签

Displaying duration inside input tag rather than pre tag

我正在尝试显示视频时长,我参考了 Kaiido 给出的这个答案 。这是代码:

<script>
          var myVideos = [];

          window.URL = window.URL || window.webkitURL;

          document.getElementById('fileUp').onchange = setFileInfo;

          function setFileInfo() {
            var files = this.files;
            myVideos.push(files[0]);
            var video = document.createElement('video');
            video.preload = 'metadata';

            video.onloadedmetadata = function() {
              window.URL.revokeObjectURL(video.src);
              var duration = video.duration;
              var duration = (new Date).clearTime()
                                .addSeconds(duration)
                                .toString('H:mm:ss');

              myVideos[myVideos.length - 1].duration = duration;
              updateInfos();
            }

            video.src = URL.createObjectURL(files[0]);;
          }


          function updateInfos() {
            var infos = document.getElementById('infos');
            infos.textContent = "";
            for (var i = 0; i < myVideos.length; i++) {
              infos.textContent += myVideos[i].duration + '\n';
            }
          }
</script>

但是,我想将值插入标签内而不是标签内。

我尝试使用 input 标签代替 pre 标签,但没有用。

如果它适用于 pre 而不适用于 input,则与 this problem: You're using innerHTML (or innerText or textContent, etc.) when you should be using value 相反。