Search code examples
jqueryhtmljquery-slider

jQuery slider default value


I am making loan calculation. I have 3 slide controls under the form fields, which controls the input value by jQuery. Here is my function:

$(function() {
    $("#loans").slider({
        range: "min",
        min: 100000,
        max: 5000000,
        value: 100000,
        slide: function(event, ui) {
            $("#loansize").val("£ " + ui.value);
        }
    });

    $("#loansize").val($("#loans").slider("value"));
});

The problem is, that I want to display the £ before the actual value. Everything works, when I move the slide control, but on the page load I only see the numeric value.

How I could make it working from the page load?

Here is the JSFiddle


Solution

  • You simply forgot to add the "£ " when you set value on pageload

    $("#loansize").val("£ " +$("#loans").slider("value"))