Home > Article > Web Front-end > How to Display Range Slider Value in a Textbox Without JavaScript?
Displaying Range Slider Value in a Textbox without JavaScript
In creating a website utilizing a range slider, the ability to display the current slide value in a textbox can be a valuable addition. While this appears like a straightforward task, it can be achieved without resorting to JavaScript or jQuery.
To accomplish this, you can capitalize on the HTML5 input type range and its oninput event listener. By assigning an oninput event to the range input, you can manipulate the value of an adjacent output element, effectively replicating the desired behavior.
Consider the following code snippet:
<input type="range" value="24" min="1" max="100" oninput="this.nextElementSibling.value = this.value"> <output>24</output>
In this instance, the oninput event handler sets the text value of the output element immediately following the range input to match the current value of the range slider. As the slider is adjusted, the displayed value is updated in real-time, mirroring the functionality traditionally achieved through JavaScript or jQuery.
The above is the detailed content of How to Display Range Slider Value in a Textbox Without JavaScript?. For more information, please follow other related articles on the PHP Chinese website!