Is there a way I can also set some label text for each steps in the HTML5 type=range control. Basically I have a range control <input type="range" step=1 min=0 max=4>
and for each steps I want some label to be shown in the control. Is there a way to do this?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
I've put together for you.
You can use jSlider. Its a jQuery slider plugin for range inputs.
https://github.com/egorkhmelev/jslider
Just check out the demos and documentation. Hope this helps.
Here's an alternative solution, no jQuery required. Uses the HTML5
oninput
event handler, andvalueAsNumber
property of the input element.Works on my machine certification: Chrome v54
There is no native way of doing it. And as input[type=range] is very poorly supported, I will recommend using jQuery UI slider and the way of attaching labels found here in answer.
OP,
I put together a demo that uses a
range
input with corresponding<p>
tags that act as both labels for the current state of the slider, as well as triggers to change the slider's value.Plunk
http://plnkr.co/edit/ArOkBVvUVUvtng1oktZG?p=preview.
HTML Markup
Javascript
CSS
Also worth nothing, if you're interested in showing the current value as a label/flag to the user, (instead of many) there's a great article by Chris Coyier on value bubbles for range sliders.
FWIW the standard (HTML 5.1, HTML Living Standard), specifies a
label
attribute foroption
s when using adatalist
. Sample code here.This isn't implemented by any browser yet.