문제

I am trying to change the background color of the Jquery slider handle as soon as it is moved or changed. I tried adding a class in the start event which worked. It added my class (with corresponding css to change the background color) but unfortunately no color changed. Fiddle: http://jsfiddle.net/cseitz/DrGYT/11/

.ui-slider .ui-slider-handle {
background: blue;
}
.updated-handle {
background: red;
}

$("#myslider").slider({
start: function (event, ui) {
    $("#myslider").slider().find(".ui-slider-handle").addClass("updated-handle");
}
});

<div id="myslider"></div>
도움이 되었습니까?

해결책

You just have to be as specific (or more specific) than your other rule. .ui-slider .ui-slider-handle is more specific than .updated-handle so it was being ignored.

Just use:

.ui-slider .updated-handle {
    background: red;
}

jsFiddle example

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top