HTML5与CSS3开发实战小记

关于output

output标签可直接计算

<form onsubmit="return false" oninput="o.value = a.valueAsNumber + b.valueAsNumber">
        <input name="a" id="a" type="number" step="any"> +
        <input name="b" id="b" type="number" step="any"> =
        <output name="o" for="a b">output>
 form>

在这里插入图片描述

关于progress

<p>这是一个进度条p>
    <progress id="p" max="100" value="0">
    progress>
    <span id="completed">0span>%
    <script>
        var progress = document.getElementById('p');
        function updateProg(newValue){
            progress.value = newValue;
            document.getElementById('completed').innerText = newValue;
        }
        var i = 0;
        var t = setInterval(function(){
            i = i + 1;
            updateProg(i)
            if(i >= 100){
                clearInterval(t);
            }
        }, 500);
    script>

HTML5与CSS3开发实战小记_第1张图片

你可能感兴趣的:(javascript)