DEV Community

Discussion on: Simple add to cart animation with CSS & JS

Collapse
 
spearsdevin profile image
Devin Spears

Love the animation! but one problem is after you can hit the add to cart you can hit the minus button and start going into the negatives with numbers.

Collapse
 
nikhil27b profile image
Nikhil Bobade

Yeah I see that I will be fix that tomorrow

Collapse
 
patrykdeja profile image
Patryk Deja • Edited

The problem is with card_value.nodeValue. Value of nodeValue used on an element returns null. So you should use an alternative for nodeValue like innerText or innerHTML.

Something like this:

if(Number(card_value.innerText) - 1 >= 0){
        card_value.textContent = cartvalue -=1;
}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
nikhil27b profile image
Nikhil Bobade

Thanks bro I just copied your and edited code. Because of you I fix today

Collapse
 
nikhil27b profile image
Nikhil Bobade

@patrykdeja is fix this code now its works fine