Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

Change the Increment Value of HTML Number Input - Decimals

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,

question from:https://stackoverflow.com/questions/26003148/change-the-increment-value-of-html-number-input-decimals

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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">

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...