How to fix the code to make it work? It gives an error Invalid left-hand side expression in postfix operation at HTMLInputElement.<anonymous>

 var range = $('.leftSide__grade__slide input[type="range"]') range.on('change', function() { if(parseInt(range.val()) ++){ console.log(1) } }) 
  • And what do you actually want to do? - meine
  • To increase the value of the slider displayed in the console 1 and at a decrease of 2. Those ++ and - but gives an error - Vladimir Bogdanovich

1 answer 1

Well, as an option:

 var $val = $("input[type='range']").val(); $("input[type='range']").on("change", function() { if (+$(this).val() > $val) { console.log("Значение увеличилось"); } else { console.log("Значение уменьшилось"); } $val = $(this).val(); }); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input type="range" min="0" max="100" />