0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

<input type="range"> のvalueが丸められる

0
Last updated at Posted at 2025-07-03

<input type="range"> の躓きメモ

JSで先にvalueを設定してもmin,max,stepの既定値で丸められるよ。
って話です。

JSの設定例
const input = document.createElement('input');
input.type = 'range';
// input.value = 0.4; //←先にvalueを設定するのはNG
input.min = 0;
input.max = 1;
input.step = 0.1;
input.value = 0.4; //←min,max,stepの後にvalueを設定しよう
document.body.append(input);
JSの設定例
const input = document.createElement('input');
input.type = 'number';
input.value = 0.4; //←ただしnumberは平気。
input.min = 0;
input.max = 1;
input.step = 0.1;
document.body.append(input);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?