user2917823
user2917823

Reputation: 199

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

Upvotes: 0

Views: 223

Answers (1)

charlietfl
charlietfl

Reputation: 171669

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

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

Upvotes: 1

Related Questions