views:

32

answers:

1

How do I check if there's any content in <textarea> ? I need to addClass based on that condition.

Many thanks

+4  A: 
if($.trim($('textarea').val()).length){
     $(this).addClass('someclass');
}
jAndy
jAndy - +1 but it may not be a bad idea to use `$.trim()` in case the markup has any whitespace.
patrick dw
@patrick: good point
jAndy