在Jquerymobile中获取滑块的值?

时间:2013-05-27 13:34:21

标签: javascript jquery jquery-mobile jquery-mobile-slider

我无法让它在jquerymobile中工作我在weightvalue变量上得到null:

JS

$("#submitWeight").on('click', function(e) {
    e.stopImmediatePropagation();
    e.preventDefault();

    submitWeight(e);
}); 

function submitWeight(e){

    var weightMonth = $("#selectMonth option:selected").text();
    var weightValue = $("#sliderWeight").slider( "option", "value");

    alert("Done");
} 

HTML

<input type="range" name="slider" id="sliderWeight" value="60" min="0" max="100" data-theme="c" >

1 个答案:

答案 0 :(得分:5)

工作示例:http://jsfiddle.net/Gajotres/s33tX/

$(document).on('pagebeforeshow', '#index', function(){ 
    alert($("#sliderWeight").val());
});