Shintaro Takechi
Shintaro Takechi

Reputation: 1365

In javascript, how can I check to see if a textarea has only one line worth of text?

I would like to make a different behavior for a textarea if textarea has more than one line worth of text.

However, by default, if I make a textarea, text area has enough height for 2 rows to begin with even without any contents.

I do not want that.

How can I check to see if I have single line in a textarea or not with javascript?

Upvotes: 0

Views: 942

Answers (1)

JGof
JGof

Reputation: 139

jQuery: $("#myTextarea").rows

vanilla JS: document.getElementById("myTextarea").rows

Upvotes: 1

Related Questions