简体   繁体   English

jQuery滑块UI问题

[英]Jquery slider UI issue

Im having trouble with the min and max values of the jQuery Slider UI. 我在使用jQuery Slider UI的最小值和最大值时遇到麻烦。 I set the min value to 5000 and the max value to 1000000 with 25000 step increments. 我将最小值设置为5000,将最大值设置为1000000,并以25000的步长递增。 However when I view it on the front-end I get the following: 但是,当我在前端查看它时,会得到以下信息:

在此处输入图片说明

Here is my code: 这是我的代码:

$( "#slider-range" ).slider({
      range: true,
      step:25000,
      min: 5000,
      max: 1000000,
      values: [ 5000, 1000000 ],
      slide: function( event, ui ) {
        $( "#657401867-MinPrice" ).val( (ui.values[ 0 ] + "").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") );
        //$( "#MinPrice" ).text( ui.values[ 0 ] );
        $( "#657401867-MaxPrice" ).val( (ui.values[ 1 ] + "").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") );
        //$( "#MaxPrice" ).text( ui.values[ 1 ] ); ($( "#slider-range" ).slider( "values", 0 ) + "").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
      }
    });

So for some reason, on the front end it has the max value as 980,000 instead of 1,000,000. 因此,由于某种原因,在前端它的最大值为980,000,而不是1,000,000。

This is probably because the step value is 25,000 . 这可能是因为step值是25,000 If you increment your min of 5,000 by 25,000 , the largest possible value is 980,000 , since your max is 1,000,000 . 如果将5,000min增加25,000 ,则最大可能值为980,000 ,因为max1,000,000 I'd recommend changing the step value to 5,000 to solve this issue. 我建议将step值更改为5,000以解决此问题。

Starting from 5,000 (your min value), in steps of 25,000 ( step value), the highest step lower than 1,000,000 (your max ) is actually 980,000. 从5,000(您的min )开始,以25,000(您的step值)为步长,低于1,000,000(您的max )的最高步长实际上为980,000。

In order to avoid this you should do on of these options: 为了避免这种情况,您应该对以下选项进行操作:

  • Change the step to be 5,000 step更改为5,000
  • Set the min value to be 0 or 25,000 min设置为0或25,000
  • Change max value to 1,005,000 max更改为1,005,000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM