1

I'm trying to use a JQueryUI slider to control the opacity of an element with the id "main-lights", but this script causes an error.

$("#slider-lamps").slider({
orientation: "vertical", 
range: "min",
value: 50,
min: 0,
max: 100
slide: function( event, ui ) {
    $( "#main-lights" ).css( "opacity", ui.values[ 0 ]);
}
});

This version works fine:

$("#slider-lamps").slider({
orientation: "vertical", 
range: "min",
value: 50,
min: 0,
max: 100
});

Can I not use a variable as the second jquery .css parameter?

How can I write this properly?

4

2 回答 2

0

您在第一个代码段中缺少,after max:100

$("#slider-lamps").slider({
    orientation: "vertical", 
    range: "min",
    value: 50,
    min: 0,
    max: 100,
    slide: function( event, ui ) {
        $( "#main-lights" ).css( "opacity", ui.values[ 0 ]);
    }
});
于 2013-11-07T23:23:08.590 回答
0
$("#slider-lamps").slider({
orientation: "vertical", 
range: "min",
value: 50,
min: 0,
max: 100**,**
slide: function( event, ui ) {
    $( "#main-lights" ).css( "opacity", ui.values[ 0 ]);
}
});

您在 max:100 之后错过了一个 ","

于 2013-11-07T23:34:55.627 回答