W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h3>如何访问 output 元素的演示</h3> <form 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"> =<output id="myOutput" name="x" for="a b"></output> </form> <p>单击该按钮可显示 output 元素的名称。</p> <p><strong>Note:</strong>Internet Explorer 不支持 output 元素。</p> <button type="button" onclick="myFunction()">试一试</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myOutput").name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>