2016-08-18 120 views
0

當我嘗試在此值更改時檢索JQuery的範圍滑塊值。 我試試這個:獲取JQuery範圍值

HTML/PHP頁面:

<div class="total"> 
     <label for="">Total</label> 
     <p><span class="monthrc"></span> Months</p> 
    </div> 

    <div class="month"> 
     <div class="input"> 
      <label for=""><span></span> Months</label> 
      <input type="text" name="range" class="range min-1 max-12" value="6" id="month"> 
     </div> 
    </div> 

    <script type="text/javascript"> 
     $("#month").slider({ 
     change: function(event, ui) {} 
     }); 
     $("#month").on("slidechange", function(event, ui) { 
     var slv = $("input[id=month]").val(); 
     $('.monthrc').append(slv); 
     }); 
    </script> 

JS頁:

options.slide = function(event, ui) { 
     elem.find('label span').empty().append(ui.value); 
     input.val(ui.value); 
    }; 
    options.value = input.val(); 
    elem.find('label span').empty().append(input.val()) 

但它不工作;(

Yazrihm, 謝謝回答

+0

控制檯中的任何錯誤? –

+0

@JNewton什麼都沒有 –

回答

0

我希望我的理解正確,因爲你並不是真正的準確性TE。

$("#month").slider({ 
 
    range: "max", 
 
    min: 1, // min value 
 
    max: 12, // max value 
 
    step: 1, 
 
    value: 6, // default value of slider 
 
    create: function(event, ui) { 
 
     $(".monthrc").html(6); // default value of slider 
 
    }, 
 
    slide: function(event, ui) { 
 
     $(".monthrc").html(ui.value); 
 
    } 
 
});
<div class="total"> 
 
    <label for="">Total</label> 
 
    <p><span class="monthrc"></span> Months</p> 
 
</div> 
 

 
<div id="month"> 
 
    <div class="input"> 
 
    </div> 
 
</div> 
 
    
 
<script src="https://code.jquery.com/jquery-3.0.0.js"></script> 
 
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" /> 
 
<script src="https://code.jquery.com/jquery-1.11.3.js"></script> 
 
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>