简体   繁体   English

重置JS中的HTML范围输入不会移动显示的滑块

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

HTML: HTML:

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

JavaScript: JavaScript的:

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

Here's a piece of my code that basically resets the rngIntro HTML range slider. 这是我的一段代码,它基本上重置了rngIntro HTML范围滑块。 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" ? 我该怎么做才能解决这个问题,我可以调用一个reset而不是.value = "0"吗?

I've just found this out for jquery mobile they require a refresh for the visual styling. 我刚刚发现了jquery mobile,他们需要刷新视觉样式。 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." “如果你通过JavaScript操作滑块,你必须调用它上面的刷新方法来更新视觉样式。”

That solved it for me. 这解决了我。

$( ".selector" ).slider( "refresh" );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM