更改HTML数字输入的递增值 - 小数 [英] Change the Increment Value of HTML Number Input - Decimals

查看:152
本文介绍了更改HTML数字输入的递增值 - 小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <$ c有什么方法可以改变在数字输入表单上使用向上/向下箭头时数字的递增量? $ c>< input type =numberstep =anyvalue =0.00000000>< / input> 

我正在使用小数字,如果上/下箭头只增加0.00000001而不是一个整数。


  • 0.00000000
  • 0.00000001

  • 0.00000002
  • 0.00000003



取代




  • 0.00000000

  • 1

  • 2
  • li> 3


我很怀疑是否有一种简单的方法可以做到这一点,尽管我会询问并查看是否有人其他人有一个解决方法或方法,因为我相信很多人都会遇到类似的问题。



谢谢,

解决方案

step 属性就是为了这个。您的代码现在具有值任意,这意味着任何值都将被接受并且步长为默认值,1.将其替换为特定数字以设置粒度和一步的大小。示例:

 < input type =numberstep =0.00000001value =0.00000000>  



注意:结束标记< / input> 在HTML5的HTML语法中无效。在XHTML语法中它是允许的,但建议使用自闭标签而不是它,例如< input type =numberstep =0.00000001value =0.00000000/>


Is there any way to change how much a number is incremented when using the up/down arrows on a HTML number input form?

<input type="number" step="any" value="0.00000000"></input>

I'm working with tiny numbers, it would be nice if the up/down arrows incremented just 0.00000001 at a time, instead of a whole number.

  • 0.00000000
  • 0.00000001
  • 0.00000002
  • 0.00000003

Instead of

  • 0.00000000
  • 1
  • 2
  • 3

I doubt very much if there is an easy way to do this, just though I'd ask and see if anyone else has a workaround or method as I'm sure many people experience a similar issue.

Thanks,

解决方案

The step attribute is for this. Your code now has the value any, which means that any values are accepted and the step size is the default, 1. Replace it by a specific number to set the granularity and the step size. Example:

<input type="number" step="0.00000001" value="0.00000000">

Note: The end tag </input> is invalid in HTML syntax for HTML5. In XHTML syntax it is allowed, but "self-closing tags" are recommended instead of it, e.g. <input type="number" step="0.00000001" value="0.00000000" />.

这篇关于更改HTML数字输入的递增值 - 小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆