I have a jquery slider and a textbox that stores the value. I’m running an asp.net application and want to load the textbox with the value if one is already stored and have the slider reflect the value. I’m thinking that a simple if statement in the jquery would do it, but i’m unfamiliar with the function.
Here is my current jquery:
$("#cultureSlider").slider({
value: 50,
min: 1,
max: 100,
step: 1,
slide: function (event, ui) {
$(".cultureScore").val("" + ui.value);
}
});
I would think something like this would work (but it doesn’t):
$("#cultureSlider").slider({
if($(".cultureScore").val() == 50){
value: 50,
} else {
value: $(".cultureScore").val(),
}
min: 1,
max: 100,
step: 1,
slide: function (event, ui) {
$(".cultureScore").val("" + ui.value);
}
});
I think your syntax is wrong… try either an inlined if (forgot the technical term) or performing the calculation outside the slider instantiation.
Method one
Method two