Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
jquery number spinner not working with float numbers

I have this JQUERY nice number spinner, but it's not stepping in floats when I give write to go by .01 digits at a time. here is the code: jquery in the head:

 <link rel="stylesheet" href="js/jquery.nice-number.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
   
  <script src="js/jquery.nice-number.js"></script>

the input and the nice number script:

<input type="number" value="1.0" name="qty" step="0.1" max="99999" min="0.1">
    <script>

        $(function () {

            $('input[type="number"]').niceNumber();

        });

    </script>

how can I solve? Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Assuming this is from: https://github.com/joshua-s/jquery.nice-number

A quick look at the source shows:

var newValue = currentValue + 1;

so the nice-number plugin is hardcoded to only add/subtract +1/-1

It does provide a callback, so you could edit the value, but might be better to edit the nice-number.js to pass in the increment step via settings.

$(function() {

  $('input[type="number"]').niceNumber({
    onDecrement: ($el, newValue, settings) => {
      $el.val(Math.round((newValue + 0.9) * 100) / 100);
      console.log($el.val())
    },
    onIncrement: ($el, newValue, settings) => {
      //console.log($el.val())
      $el.val(Math.round((newValue - 0.9) * 100) / 100);
      console.log($el.val())
    }
  });

});
<!--<link rel="stylesheet" href="js/jquery.nice-number.css">-->
<link ref="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.nice-number@2.1.0/dist/jquery.nice-number.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<!--<script src="js/jquery.nice-number.js"></script>-->
<script src="https://cdn.jsdelivr.net/npm/jquery.nice-number@2.1.0/dist/jquery.nice-number.js"></script>


<input type="number" value="1.0" name="qty" step="0.1" max="99999" min="0.1" style='width:200px;'>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda