iloveprjaniki iloveprjaniki - 1 year ago 91
Javascript Question

How to Convert String to Number in Javascript

I have this line of code:


and I'm trying to figure out how can I add a number, say 5 or 8, or 10 or whatever to this value, but in one line?

I tried this one, but it didn't work:

parseInt("(($(".contact-msg-inpt").prop("scrollHeight"))", 10)

Answer Source

Simply by doing :

var result = parseInt($(".contact-msg-inpt").prop("scrollHeight"))+10;

You have to parse the value first then add the number to it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download