JQuery counter initial value not set

I am using jQuery spinner control in my web form. But this initial value is not set. I am using IE9 + VS2010

Here is the code I wrote in my generic function. I call this function at runtime and send the parameters accordingly.

function(spinnerid, minval, maxval, initvalue, step) { $("#" + spinnerid).spinner({ min: minval, max: maxval, increment: step, value: initvalue }); } 

These are the libraries that I use:

 <script type="text/javascript" src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script> <link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" /> 

And this is the HTML:

 <input type="text" id="income" class="income" /> 
+4
source share
4 answers

I do not know why the value parameter does not work as documented. I tried this myself and have the same problem. This will solve your problem though ...

 function setSpinner(spinnerid, minval, maxval, initvalue) { $("#" + spinnerid).spinner({ min: minval, max: maxval }).val(initvalue); } 

I just added val() at the end to set the initial value. (I also added a function name, simply because you missed it in your question. Name it what you need.)

+11
source

There is no value option in spinner . You will need to use .val() as suggested by @Archer.
Also, another problem is increment , you mean incremental . Or step if you are trying to pass a number. Check the related documentation.

So your function becomes

 function(spinnerId, min, max, init, step) { $('#' + spinnerId) .spinner({min:min, max:max, incremental /*or 'step'?*/:step}) .val(init) ; } 

ref: spinner API

+3
source

Is it possible that you are confusing jQueryUI with jQuery EasyUI ?
Your .spinner() call is exactly like easyUI ...
See my other answer for using jQueryUI correctly

0
source

also use jquery default library ... http://jquery.com/download/

-1
source

Source: https://habr.com/ru/post/1442305/


All Articles