我有这段代码,它执行没有错误,每次滑块更改时,它都会在调试控制台中显示“**滑块更改**”。但我无法弄清楚如何捕获滑块的值,以便将其存储在 var 中。你能帮忙吗,我希望这是一件简单的事情。
$('#page4_Options').live('pageinit', function(event) {
var slideTime = userOptions.getSlideTime() / 1000; // userOptions is my Object to get/set params from localStorage.
$("input[id='slider']").val(slideTime).slider("refresh"); // set default slide time when page init's.
console.log("userOptions.getSlideTime()", userOptions.getSlideTime());
$("#slider").bind("slidestop", function(event, ui) {
console.log("** slider change **");
// How do I capture the new slider value into a var?
});
});
这是带有滑块的 HTML,它位于标签中:
<div data-role="fieldcontain">
<label for="slider">Slide Duration (seconds):</label>
<input type="range" name="slider" id="slider" value="2" min="0" max="60" />
</div>