tags:

views:

25

answers:

2

I have TextArea. on buttonclicking I alert

alert($("#textarea1").scrollHeight);

but i get undefined. How to get it?

+2  A: 

try this instead:

alert($("#textarea1")[0].scrollHeight);
Darin Dimitrov
thankyou can you tell why to put [0]? I have one only textarea
Mario
scrollHeight is not a jQuery property, it is a DOM property. jQuery selectors always return arrays, because it is not known in advance how many elements your selector will match. As you are using an ID selector you know that "normally" only one element should be returned, so you select the first element from the returned array and invoke call the scrollHeight property on it.
Darin Dimitrov
thankyou is there jquery property to do same thing?
Mario
A: 
alert($("#textarea1").css('height')); ?
FrankBr