user6561435 user6561435 - 1 year ago 117
jQuery Question

JQuery Slider Value from next Element

I have a set of JQuery sliders and corresponding value textboxes on my page.

All is working fine and the sliders and textboxes are updating each other on a change. My only remaining issue is setting the initial values on the page load.

Using the class of the corresponding object works (yellow highlight), but in my other example (blue highlight) I need to use the next() function as these elements are in a repeater.

What is the best way to set the initial slider value in the blue examples on the page load?


Example Code Here

Answer Source

The each() function seems to do the trick here:

$(".compDiscSlider").each(function () { var val = $(this).next("input").val(); $(this).slider({ range: "min", animate: true, step: 0.25, min: 0.00, max: 100.00, value: val, slide: function (event, ui) { $(this).next("input").val(ui.value); } }) });

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download