I’m new in jquery and javascript coding and I tried to write a function that restores an initial value on a textarea if the length of its value is less than “n” characters. It doesn’t work. Can you explain me how to do that?
Here’s the code:
$("textarea").focus(function() {
var text = $(this).val();
$(this).val('');
$(this).blur(function() {
if($(this).val().lenght<20)
{
$(this).val(text);
}
});
});
Though not very efficient, this would do the work: