Thursday, 15 August 2013

javascript - How to split decimal -



javascript - How to split decimal -

this question has reply here:

get decimal portion of number javascript 10 answers

how split decimal alert(

cm = 14*2.55; outputcmval = math.round(cm*10)/10; alert(outputcmval); //35.7 arrdecimal = outputcmval.split('.'); alert(arrdecimal[1]); //want alert 7 outputcmval

http://jsfiddle.net/iwebsmile/2lenx3es/

split() method fellow member of string. since outputcmval number, need phone call .tostring() method before .split('.')

arrdecimal = outputcmval.tostring().split('.'); demo: http://jsfiddle.net/91m6kmqw/

javascript jquery

No comments:

Post a Comment