如何:2 jQuery UI Slider 1.8.14

时间:2011-08-02 13:59:41

标签: jquery user-interface slider

我试图将两个滑块放在同一个窗体中;但我无法让第二个工作。 是否可以在同一页面上有两个滑块? 如果是的话,我应该怎么做?

使用的代码:

$(function() {
    $( "#slider-range" ).slider({
        range: true,
        min: 0,
        max: 2000000,
        values: [ 125000, 500000 ],
        slide: function( event, ui ) {
            //$( "#amount" ).val( "£" + ui.values[ 0 ] + " - £" + ui.values[ 1 ] );
            $( "#PriceMin" ).val( ui.values[ 0 ]);
            $( "#PriceMax" ).val( ui.values[ 1 ]);
            $("#amount").text("Price: £" + $("#slider-range").slider("values",0) + " - £" + $("#slider-range").slider("values",1));
        }
    });
    //$( "#amount" ).val( "£" + $( "#slider-range" ).slider( "values", 0 ) + " - £" + $( "#slider-range" ).slider( "values", 1 ) );
    $("#amount").text("Price: £" + $("#slider-range").slider("values",0) + " - £" + $("#slider-range").slider("values",1));

    $("#slider-range-rooms").slider({
        range: true,
        min: 0,
        max: 6,
        values: [ 1, 3 ],
        slide: function( event, ui ) {
            //$( "#rooms" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
            $( "#roomMin" ).val( ui.values[ 0 ]);
            $( "#roomMax" ).val( ui.values[ 1 ]);
            $("#rooms").text("Rooms: " . $("#slider-range-rooms").slider("values",0) + " - " + $("#slider-range-rooms").slider("values",1) );
        }
    });
    //$( "#rooms" ).val( $( "#slider-range-rooms" ).slider( "values", 0 ) + " - " + $( "#slider-range-rooms" ).slider( "values", 1 ) );     
    $("#rooms").text("Rooms: " . $("#slider-range-rooms").slider("values",0) + " - " + $("#slider-range-rooms").slider("values",1) );
});

1 个答案:

答案 0 :(得分:3)

我在那里看到了PHP连接。尝试更改:

$("#rooms").text("Rooms: " . $("#slider-range-rooms").slider("values",0) + " - " + $("#slider-range-rooms").slider("values",1) );

$("#rooms").text("Rooms: " + $("#slider-range-rooms").slider("values",0) + " - " + $("#slider-range-rooms").slider("values",1) );