tags:

views:

40

answers:

2

jQuery possible to Detect when a user is in a Textarea and when they leave? so I could make a textarea height = 15px when the user isn't focused on it...

But when the user does click and focus on the textarea it gets a height of 50px?

+4  A: 

Try something like this:

$('#textareaID').focus(function() {
   $(this).height(50);
}).blur(function() {
   $(this).height(15);
});
Jacob Relkin
that's awesome. I'll add this to my application.js... Only thing is not all pages will have this element. Is there a way I should detect,,, like,,, if it exists then bind? or does jQuery does this automatically?
WozPoz
@WozPoz - jQuery does that for you. ^_^ automatically
Reigel
A: 

You can also try the jQuery plugin autoResize to have a Facebook-like behavior.

xmarcos