W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>单击该按钮以创建一个 OUTPUT 元素。</p> <form id="myForm" oninput="x.value=parseInt(a.value)+parseInt(b.value)">0 <input type="range" id="a" value="50">100 +<input type="number" id="b" value="50">= </form> <button onclick="myFunction()">试一试</button> <p id="demo"></p> <script> function myFunction() { var x = document.createElement("OUTPUT"); x.setAttribute("name", "x"); x.setAttribute("for", "a b"); document.getElementById("myForm").appendChild(x); document.getElementById("demo").innerHTML = "output 元素已创建。请更改 range 或 number 字段的值以查看计算结果。"; } </script> </body> </html>