- Joined
- Oct 24, 2013
- Messages
- 47
- Reaction score
- 0
I am using the following code to convert data attribute values to Numbers. I want to get a valid numeric value or 0 in all cases. e.g if the data attribute value is blank("") then I need 0 in that case.
I am using the following code to convert data attribute values to Numbers. I want to get a valid numeric value or 0 in all cases. e.g if the data attribute value is blank("") then I need 0 in that case. The intention is to avoid getting NaN because I am using the result in calculations.
I am using the following code to convert data attribute values to Numbers. I want to get a valid numeric value or 0 in all cases. e.g if the data attribute value is blank("") then I need 0 in that case. The intention is to avoid getting NaN because I am using the result in calculations.
JavaScript:
Number($("td[id^='tdCumulativeUnderOverSpendPrevious']").data("val") || 0);
Last edited: