Javascript HTML 中的上下数字?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10472997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 01:28:52  来源:igfitidea点击:

A numeric up and down in HTML?

javascriptjqueryhtml

提问by Hunter Mitchell

Is there a numeric up and down in HTML?

HTML中是否有数字上下?

回答by Matt Ball

Use an HTML5 <input type="number"/>.

使用 HTML5 <input type="number"/>

More reading at Dive Into HTML5. Browser compatibility tables at When can I use Number input type?

Dive Into HTML5阅读更多内容。浏览器兼容性表何时可以使用数字输入类型?

回答by MMeah

There are plenty of numeric steppers out there. Look for "numeric stepper" or "numeric spinner".

那里有很多数字步进器。寻找“数字步进器”或“数字微调器”。

http://xflatlinex.github.io/Numeric-Stepper/

http://xflatlinex.github.io/Numeric-Stepper/

回答by Black

Use the tag inputwith type="number"

使用标签inputtype="number"

<input type="number">

Here is a usage example on how to use the NumericUpDown:

下面是一个关于如何使用 NumericUpDown 的用法示例:

document.getElementById("square").addEventListener("click", function() {
  var result = document.getElementById("result");
  var nudMax = document.getElementById("max").value;

  result.innerHTML = nudMax * nudMax;
});
<label for="max">Max</label>
<input id="max" type="number">

<button id="square">Square</button>

<br>

<label for="result">Result:</label>
<output id="result"></output>