-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,364
  • 1
  • 19
  • 34

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,435
  • 11
  • 25
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,564
  • 14
  • 13
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
  • 261
  • 2
  • 4