Skip to content
Advertisement

Why i keep getting this Total: £NaN when i hit remove button ,instead of Total:£19.99 .? Nan Error is not goin away i dont think i have any more idea

Why do I keep getting this Total: £NaN when I hit the remove button, instead of Total:£19.99 .? Nan Error is not going away I don’t think I have any more idea What am I doing wrong guys. and I would like it to display the total value but it keeps Total NAN Thanks for helping

JavaScript
JavaScript

Advertisement

Answer

You have at least two typos. There is a single quote at the end of your JavaScript code and you have var quantity = quantityElement.Value; instead of var quantity = quantityElement.value;. After I fixed it quantity is undefined and price * quantity is NaN.

The selector

JavaScript

returns this element

JavaScript

This element doesn’t have a value attribute. You mean

JavaScript

This element can be selected with

JavaScript

Example:

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