2

When I add float numbers in value="3.4567890", it converts to number type 'int'. I don't want it convert to number type 'int'. I want it to be 'number' or type 'float'.

Example:

const rangeValue = document.querySelector('input');
console.log(rangeValue.value);
<input type="range" min="0" max="0" value="3.4567890">

console.log converts to number type int.

1
  • 1
    An input's value attribute is never type 'int', as there is no integer type in JavaScript. It is also not type 'number'. Input value is always type 'string'. Commented Jan 4, 2021 at 22:00

1 Answer 1

2

The max attribute should be above the value for the value to be retrieved properly. (Right now, your min is the same as your max, at 0)

Set a step attribute to a very low amount, like 0.0000001:

const rangeValue = document.querySelector('input');
console.log(rangeValue.value);
<input type="range" min="0" max="10" step="0.0000001" value="3.4567890">

Sign up to request clarification or add additional context in comments.

1 Comment

This technically answers the question but I have yet to see an application where 0.0000001 is the desired step value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.