user6561435 user6561435 - 4 months ago 17
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?

Thanks

Example Code Here

Answer

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); } }) });