Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

dynamically change the color of a slider component

I wan't to change the color of a slider component based on it's value.

I can get its value on the on change event with something like:

codevar value = $(this).closest("input").val();/code

I can change the color of the value field with:

codeif (value === "1") {
$(this).css("color","red");
} else if (value === "3") {
$(this).css("color","blue");
} else if (value === "5") {
$(this).css("color","green");
}/code

What I would like to do is make it change the entire control

Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

dynamically change the color of a slider component

Hello,

Please use JS code below for that:
pre$(this).closest(".ui-field-contain").find(".ui-slider-track").css("background", "red");/pre

instead of pre$(this).css("color","red");/pre

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

dynamically change the color of a slider component

Great, works good

Return to “Issues”