Search code examples
jqueryuislider

how to show the UI Slider value in two different fields?


i am tying to show the UI range slider value in input box. i have done this but i want show the same value on another also, that span is in another .

here i am getting the slider value on this input box but the same value must reflect on another div's also.

How do i do it , help me out of this

$("#slider").slider({
    range: "min",
    value: 1,
    step: 10,
    min: 210,
    max: 850,
    slide: function (event, ui) {
        $(".inputCount").val(ui.value);
        $(".borrowMonth").val(ui.value);
    }
});
$(".inputCount").change(function () {
    $("#slider").slider("value",this.value);
});
<div id="slider"></div>
<label>£</label>
<input type="text" value="200" class="inputCount"/>

<div class="borrowMonth">£ <span>200</span> </div>


Solution

  • You using the wrang method - "val" for the element. And you need chnage the selector. This is working variant:

    $(".borrowMonth span").text(ui.value);
    

    Full example here: http://jsfiddle.net/s1hfkgr2/