Basic Javascript Help

I have some basic HTML and assigned an ID

<div id="somecontent">48793748</div>

I want to find the number value of the div

so I know its something like

document.getElementById("somecontent")

I need to assign a variable and end up with the value being a number

If I do a document.getElementById("somecontent").innerHTML
I get "48793748" but its a string not a number.  How do I convert or change the getElementById so that it returns a number?
Baub EisAsked:
Who is Participating?
 
GaryCommented:
parseFloat(document.getElementById("somecontent").innerHTML)
0
 
GaryCommented:
parseInt(document.getElementById("somecontent").innerHTML)
0
 
Baub EisAuthor Commented:
that drops info past the decimal point.

39.000329 returns 39

How can I get it to return the value of 39.000329 from the element?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Baub EisAuthor Commented:
parseFloat got it
0
 
Baub EisAuthor Commented:
so can I assign a variable with it?

var myvar = parseFloat(document.getElementById("somecontent.innerHTML)

?
0
 
GaryCommented:
Yep
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.