Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resetting HTML Range Input in JS doesn't move displayed slider

HTML:

<input type = "range" id = "rngIntro" min = "0" max = "5" value = "0">

JavaScript:

document.getElementById("rngIntro").value = "0";

Here's a piece of my code that basically resets the rngIntro HTML range slider. It changes the value of it when the function is called, but it leaves the physical slider at whatever value it was prior. So, if the slider was at the far right it would stay there even though the value does change to zero.

What can I do to fix this, is there a reset I can call instead of .value = "0"?

like image 999
user3562657 Avatar asked Oct 31 '22 14:10

user3562657


1 Answers

I've just found this out for jquery mobile they require a refresh for the visual styling. Here's what they say in this page:

"If you manipulate a slider via JavaScript, you must call the refresh method on it to update the visual styling."

That solved it for me.

$( ".selector" ).slider( "refresh" );
like image 132
Israel Gav Avatar answered Nov 12 '22 17:11

Israel Gav