တန်ဖိုး ရွေးရန် Slider (type="range")
HTML Living Standard
Slider နဲ့ ခန့်မှန်းဂဏန်း ရွေးပါ။ တန်ဖိုးအတိအကျ မြင်ရဖို့လိုရင် ဘေးမှာ တန်ဖိုး ပြပေးပါ။
Code စမ်းလို့ရတဲ့ သင်ခန်းစာ ဖွင့်ရန်
ဒီစာမျက်နှာမှာ
Attribute နဲ့ အလုပ်လုပ်ပုံ
| တန်ဖိုး သို့မဟုတ် ရေးပုံ | အလုပ်လုပ်ပုံ |
|---|---|
min="0" / max="100" | မူလ အနိမ့်ဆုံး 0 နဲ့ အမြင့်ဆုံး 100 ပါ။ |
step="5" | တစ်ဆင့်ကို ငါးစီ ရွှေ့ပါတယ်။ |
value="25" | Slider ရဲ့ စတင်နေရာ သတ်မှတ်ပါတယ်။ |
နမူနာကို စမ်းကြည့်ပါ
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Range slider</title>
<style>
form { display: grid; gap: 12px; justify-items: start; } output { display: block; margin-top: 10px; }
</style>
</head>
<body>
<form id="demo">
<label>Volume <input type="range" name="volume" min="0" max="100" step="5" value="25" oninput="level.value = this.value"></label>
<output id="level">25</output>
<button type="submit">Check</button>
</form>
<output id="response"></output>
<script>
const form = document.querySelector('#demo');
form.addEventListener('click', event => {
const submitter = event.target.closest('[type="submit"], [type="image"]');
if (!submitter) return;
event.preventDefault();
if (!form.noValidate && !submitter.formNoValidate && !form.reportValidity()) return;
const values = new FormData(form, submitter);
document.querySelector('#response').textContent =
'Passed validation. Fields received: ' + [...values.keys()].join(', ');
});
</script>
</body>
</html>
စမ်းကြည့်ရင် ဘာဖြစ်မလဲ Slider ရွှေ့ရင် ဘေးက ဂဏန်း ငါးစီပြောင်းတာ တွေ့ရပါမယ်။