I have a slider that when loading the page should give a value in the slider handles, as well as another value for the label. I cannot understand why when I load the page I get NaN, but when I move the sliders, a value appears.
Please take a look so that you can see for yourself Fiddle
The code looks fine, although the values ββdo not appear in the descriptors when the page loads.
$("#slider1").slider({ max:350, min:100, step:10, value:100, animate: 'true', slide: function(event, ui) { $("#amount").val(ui.value); $(this).find('.ui-slider-handle').html('<div class="sliderControl-label v-labelCurrent">Β£'+ui.value+'</div>'); update(); } }); function addDaysToDate(days) { var mths = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); var d = new Date(); d.setHours(d.getHours() + (24 * days)); var currD = d.getDate(); var currM = d.getMonth(); var currY = d.getFullYear(); return mths[currM] + " " + currD + ", " + currY; } $("#slider2").slider({ max:30, min:7, value:7, animate: 'true', slide: function(event, ui) { $("#days").val(ui.value); $(this).find('.ui-slider-handle').html('<div class="sliderControl-label v-labelCurrent">'+ui.value+'<span class="unit"> days</span></div>'); $("#date").text(addDaysToDate(parseInt($("#days").val()))); update(); }, create: function(event, ui) { $("#date").text(addDaysToDate(parseInt($("#days").val()))); } }); $("#days").val($("#slider2").slider("value")); $("#days").change(function(event) { var data = $("#days").val(); if (data.length > 0) { if (parseInt(data) >= 7 && parseInt(data) <= 31) { $("#slider2").slider("option", "value", data); } else { if (parseInt(data) < 1) { $("#days").val("7"); $("#slider2").slider("option", "value", "7"); } if (parseInt(data) > 31) { $("#days").val("31"); $("#slider2").slider("option", "value", "31"); } } } else { $("#slider2").slider("option", "value", "7"); } $("#date").text(addDaysToDate(parseInt($("#days").val()))); }); update();