0

I have two sliding bars and I want to get the value the user sets them to and do some maths on it. var days and var total are my attempts to do this. I was taking it that the UI slider stores its values as stings and not integers. But both my attempts below, then use either just return a NaN value? So what am I doing wrong?

var days = parseInt($(this).attr('#day_output'), 10);
var total = parseInt($('#amount_outputTotal'));
var fees = 5;
var valueout;

valueout = 60 * days + fees;

$(document).ready(function() {
    $('#Output').html(valueout);
});

Many Thanks Glenn.

4

2 回答 2

0

我们的项目之一使用 jqueryUI ahs 以下代码:

fixed = $().fixFloat(ui.value);

我知道这可能不适合您的需求。

尝试从 parseInt 更改为 parseFloat 并通过控制台输出:

$(this).attr('#day_output')

为什么这里没有 .attr 或 .val 之类的东西?

$('#amount_outputTotal')
于 2012-09-25T11:45:23.497 回答
0

为什么作为数字表示的滑块将值存储为字符串?您可以使用以下代码获取值(或值,如果有两个句柄)

var val_single = $('#your_slider').slider('value');

var val_array = $('#your_slider').slider('values');

请 rtfm http://jqueryui.com/demos/slider/

于 2012-09-25T10:04:35.790 回答