It looks like I’m just zatroil, but I do not understand how to make banalism.

Условие ? тогда минус : тогда плюс; var Value = $('Элемент').val(); $('Элемент').val(+Value Минус/Плюс 100 ); 

I don’t understand how to transfer the minus or plus of the first condition to the element value. After all, if you assign a thread to the variable '-' or '+' and pass it to

$ ('Element'). Val (+ Value Minus / Plus 100);

then it will be just a string. Arithmetic manipulation can be added to the first condition, but somehow it is not correct. It turns out almost the same code in two places.

thank

    1 answer 1

     var factor = Условие ? -1 : 1; $('Элемент').val(+Value + factor * 100); 
    • one
      Plus, but frankly, it complicates readability. - MedvedevDev
    • oh, cool) all genius is simple)) - Gagablik