当前位置: 动力学知识库 > 问答 > 编程问答 >

jQuery UI slider in Internet Explorer

问题描述:

I put this slider in my project but in internet explorer 8 it doesn't work.

this is the code:

$(function() {

$( "#slider-range" ).slider({

range: true,

min: 0,

max: 600,

values: [ 100, 500 ],

slide: function( event, ui ) {

$( "#amount" ).val( "€" + ui.values[ 0 ] + " - €" + ui.values[ 1 ] );

}

});

$( "#amount" ).val( "€" + $( "#slider-range" ).slider( "values", 0 ) +

" - €" + $( "#slider-range" ).slider( "values", 1 ) );

});

Can anyone help me?

网友答案:

Did you included required files ? They are at the bottom of the documentation page.

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
网友答案:

Well, you have two problems.

1) JQuery 2.X.X is not supported by IE8. You must use JQuery 1.X.X.

2) I removed ui and event as parameters frokm the function called in slide, because it is the way jquery-ui examples are. I think it's for compatibility reasons, but the way that it was before should work on IE8 as well.

$(function() {
    $( "#slider-range" ).slider({
        range: true,
        min: 0,
        max: 600,
        values: [ 100, 500 ],
        slide: refreshValues
    });
});

var refreshValues = function() {
    $( "#amount" ).val( "€" + $( "#slider-range" ).slider( "values", 0 ) +
        " - €" + $( "#slider-range" ).slider( "values", 1 ));
}

Well, this will do the trick.

分享给朋友:
您可能感兴趣的文章:
随机阅读: