Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
153
rated 0 times [  158] [ 5]  / answers: 1 / hits: 7001  / 10 Years ago, fri, july 18, 2014, 12:00:00

I have a pair of inputs that are text and range types respectively


<input type=range min=100 max=100000 val=1000 step=1000 id=priceSliderMin></input>`
<input type=text id=priceTextMin></input>

I also have a pair of jQuery functions that update the partner input as the other changes.


$('#priceSliderMin').change(function(event){
$('#priceTextMin').prop('value', parseInt($('#priceSliderMin').prop('value')));
});
$('#priceTextMin').keyup(function(event){
$('#priceSliderMin').prop('value', parseInt($('#priceTextMin').prop('value')))
})

The problem is that the slider doesn't update the text field until I release the mouse button. Is there a way I could update it as it moves? I found an example using raw JavaScript that seems to work, but I can't replicate it with jQuery, even when using Chrome.


More From » html

 Answers
3

If you view the source of that page with the example, they are actually using oninput to listen to the changes while dragging (the posted source code shows onchange, which doesn't trigger until dragging is complete). To do this in jQuery, try this...



$('#priceSliderMin').on('input', function(){
$('#priceTextMin').val($('#priceSliderMin').val());
});


Demo - Fiddle


[#43787] Thursday, July 17, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pranavrorys

Total Points: 466
Total Questions: 87
Total Answers: 115

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
;