Почему не работает прокрутка мышкой в input?

$('input[name="price"]').val(42.55);
$('input[name="price"]').on('mousewheel', function(e){
  let step = 0.01;
  let val = parseFloat($(this).val());
  if(e.originalEvent.wheelDelta / 120 > 0) {
    $(this).val(val + step);
    console.log('Увеличение цены');
  }else{
    $(this).val(val - step);
    console.log('Уменьшение цены');
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="price" value="">


Ответы (1 шт):

Автор решения: MyNameIsKitsune

Попробуй вместо mousewheel установить wheel, или замени on на bind

Например: $('input[name="price"]').on('wheel', function(e){ ...

Рабочий вариант:

$('input[name="price"]').val(42.55);
$('input[name="price"]').on('wheel', function(e){
  let step = 0.01;
  let val = parseFloat($(this).val());
  if(e.originalEvent.wheelDelta / 120 > 0) {
    $(this).val(val + step);
    console.log('Увеличение цены');
  }else{
    $(this).val(val - step);
    console.log('Уменьшение цены');
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="price" value="">

→ Ссылка