Wednesday 15 February 2012

javascript - How to get jQuery Simple Slider to show initial value? -



javascript - How to get jQuery Simple Slider to show initial value? -

i can't seem jquery simple slider (http://loopj.com/jquery-simple-slider/) initialse span shows slider value before dragged. span updated slider dragged , code update span in same bind, looks me slider:changed event gets caught slider:ready doesn't.

<form> <input name="slider" type="text" data-slider="true" data-slider-highlight="true" data-slider-step="1" data-slider-range="1,99" value="20"> </form> $("[data-slider]") .each(function () { var range; var input = $(this); $("<span>").addclass("output") .insertafter(input); range = input.data("slider-range").split(","); $("<span>").addclass("range") .html(range[0]) .insertbefore(input); $("<span>").addclass("range") .html(range[1]) .insertafter(input); $(this).bind("slider:ready slider:changed", function (event, data) { $(this).nextall(".output:first") .html(data.value.tofixed(2)); }) });

however, examples given simpleslider author appear show initial slider values, can't see i'm doing differently prevents mine working.

please see fiddle here http://jsfiddle.net/nickweavers/77c89pju/23/

you can add together value first time manually, think that's simpler approach.

http://jsfiddle.net/77c89pju/26/

the code write in end of anonymous function called in each loop of "data-slider" is:

$(this).nextall(".output:first").html($(this).val());

javascript jquery

No comments:

Post a Comment