-3

I have this line of code:

($(".contact-msg-inpt").prop("scrollHeight"))

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)

Daniel
  • 1,342
  • 1
  • 20
  • 32

3 Answers3

2

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.

Sletheren
  • 2,287
  • 7
  • 23
0

It doesn't work because you are literally trying to parse the string ($(".contact-msg-inpt").prop("scrollHeight")) as an int. And furthermore this string is incorrect because of the quotes inside.

Loose the quotes at the beginning and end. The extra parantheses are not needed as well.

parseInt($(".contact-msg-inpt").prop("scrollHeight"), 10)
Björn Tantau
  • 1,524
  • 14
  • 11
0

scrollHeight is a readonly property, you can't change it, change the element height / padding / using css or styles.

see this answer here: https://stackoverflow.com/a/22675563/1243058

8DX
  • 251
  • 2
  • 4