Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In js, strings and numbers are added. How to get them to add numbers?
In js, strings and numbers are added. How to get them to add numbers?
You need to use the parseInt function to convert the resulting string Into int type and add it.

For example, documents. Getelementbyid(“DVD number "). Value =?

document . getelementbyid(" DVD number ")。 Value+1;

If you don't use the ParseInt function, you will only get the result of spelling "1" to the original string.

If you want to run it logically, you should add the parseInt function:

document . getelementbyid(" DVD number ")。 value = parseInt(

document . getelementbyid(" DVD number ")。 Value)+1;

Extended data:

ParseInt function can convert strings to integer types.

The parseDouble function can convert a string into a Double type.

The parseFloat function can convert a string to a floating-point type.