Skip to content
Advertisement

Button Increment or Decrement for quantity – JS

I am trying to increase and decrease the quantity but when i click on the + or -, the input number doesn’t change but still remains the default value 1.

JavaScript

Advertisement

Answer

It is only a problem related to when your <script></script> is loaded. Your code works when the script is loaded after your DOM. Maybe you can consider this answer to see where to put script tag inside an html.

Also I added the class panel inside your html: <div class="panel"></div> .

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement